Advertisement
9551

Untitled

Jul 1st, 2021 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.10 KB | None | 0 0
  1. ----------------------MENU/PANEL API-------------------
  2. --------------------by elektrobom1!--------------------
  3. ---Copyright (c) 2021-2022 9551------------9551#0001---
  4. ---using this code in your project is fine!------------
  5. ---as long as you dont claim you made it---------------
  6. ---im cool with it, feel free to include---------------
  7. ---in your projects!   discord: 9551#0001--------------
  8. ---you dont have to but giving credits is nice :)------
  9. -------------------------------------------------------
  10. -------------------------------------------------------
  11. --*!   pastebin get LTDZZZEJ button
  12.  
  13. --*functions usages
  14. --*API(ins, cord1, cord2, length, height)
  15. --*timetouch(timeout,monitor)
  16. --*touch()
  17. --*button(monitor, ins, cord1, cord2, text)
  18. --*counter(monitor, ins, cc, cord1, cord2, cv, max, min, col)
  19. --*fill(monitor, pos1, pos2, length, height)
  20. --*switch(monitor, ccins, pos1, pos2, col1, col2, col3, text)
  21. --*switchn(monitor, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  22. --*bundle(side, color, state)
  23. --*signal(side, ins, col)
  24. --*sliderVer/Hor(monitor, ins, cc, pos1, pos2, length, color1, textCol)
  25. --*local function menu(monitor, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)  (returns menuout)
  26. --*bar(monitor, pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
  27. --*timeswitch(monitor, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  28. --*render(monitor,text,x,y,textcol,backCol)
  29. --*menudata()
  30. --*frame(monitor, pos1, pos2, length, height, color3, color1, thicc)
  31. --*db allows you to get stored data from all functions that use stored data!
  32. --*how to use db:  in your function for example switch you do   b.switch("db",<data>) data is the storing position you want to get data of
  33.  
  34.  
  35.     --base API this API is made for detecting clicks in an area
  36.     local monitor = {}
  37.     function monitor.API(ins, cord1, cord2, length, height)
  38.         if ins == true then
  39.             ins = {os.pullEvent("monitor_touch")}
  40.         end
  41.         if ins[3] >= cord1 and ins[3] <= cord1 + length-1 then
  42.             if ins[4] >= cord2 and ins[4] <= cord2 + height-1 then
  43.                 return true
  44.             else
  45.                 return false
  46.             end
  47.         end
  48.     end
  49.    
  50.        
  51.         function monitor.touch()
  52.             local dats = {os.pullEvent("monitor_touch")}
  53.             return dats
  54.         end
  55.        
  56.     function monitor.timetouch(timeout, mon)
  57.             local timer = os.startTimer(timeout)
  58.             while true do
  59.                 local event = {os.pullEvent()}
  60.                 if (event[1] == "timer") and (event[2] == timer) then
  61.                     if mon == nil then
  62.                         local monitor = "timeout"
  63.                     end
  64.                     return {"timeout", mon, 1000, 1000}
  65.                 elseif (event[1] == "monitor_touch") and (event[2] == mon) then
  66.                     return {event[1], event[2], event[3], event[4]}
  67.                 end
  68.             end
  69.         end
  70.        
  71.         -------------------------------------------------------------------------------------------------
  72.        
  73.         function monitor.button(mon, ins, cord1, cord2, text)
  74.             if ins[2] == mon then
  75.                 if ins ~= nil then
  76.                     m = peripheral.wrap(mon)
  77.                     x = monitor.API(ins, cord1, cord2, string.len(text), 1)
  78.                     m.setCursorPos(cord1, cord2)
  79.                     m.write(text)
  80.                     return x
  81.                 end
  82.             end
  83.         end
  84.        
  85.         function monitor.counter(mon, ins, cc, cord1, cord2, cv, max, min, col)
  86.             if mon == "db" then
  87.                 if data == nil then
  88.                     return nil
  89.                 else
  90.                     return data[ins]
  91.                 end
  92.             end
  93.             if mon == "setdb" then
  94.                 if data == nil then
  95.                     return "no data to edit"
  96.                 else
  97.                     data[ins] = cc
  98.                     return("value changed too "..type(cc))
  99.                 end
  100.             end
  101.             if ins[2] == mon then
  102.                 if ins ~= nil then
  103.                     local m = peripheral.wrap(mon)
  104.                     if data == nil then
  105.                         data = {}
  106.                         for is = 0, 1000 do
  107.                             data[is] = 0
  108.                         end
  109.                     end
  110.                     m.setCursorPos(cord1, cord2)
  111.                     m.write("\24" .. " " .. data[cc])
  112.                     m.setCursorPos(cord1, cord2 + 1)
  113.                     m.write("\25")
  114.                     if monitor.API(ins, cord1, cord2, 1, 1) == true then
  115.                         if data[cc] < max then
  116.                             data[cc] = data[cc] + cv
  117.                             m.setCursorPos(cord1, cord2)
  118.                             m.setTextColor(colors.green)
  119.                             m.write("\24" .. " " .. data[cc] .. " ")
  120.                             m.setCursorPos(cord1, cord2 + 1)
  121.                             m.setTextColor(colors.red)
  122.                             m.write("\25")
  123.                             m.setTextColor(colors[col])
  124.                             return data[cc]
  125.                         end
  126.                     end
  127.                 end
  128.                 if monitor.API(ins, cord1, cord2 + 1, 1, 1) == true then
  129.                     if data[cc] > min then
  130.                         data[cc] = data[cc] - cv
  131.                         m.setCursorPos(cord1, cord2)
  132.                         m.setTextColor(colors.green)
  133.                         m.write("\24" .. " " .. data[cc] .. " ")
  134.                         m.setCursorPos(cord1, cord2 + 1)
  135.                         m.setTextColor(colors.red)
  136.                         m.write("\25")
  137.                         m.setTextColor(colors[col])
  138.                         return data[cc]
  139.                     end
  140.                 end
  141.             end
  142.         end
  143.        
  144.         function monitor.fill(mon, pos1, pos2, length, height)
  145.             local m = peripheral.wrap(mon)
  146.             for x = 0, height - 1 do
  147.                 m.setCursorPos(pos1, pos2 + x)
  148.                 m.write(string.rep(" ", length))
  149.             end
  150.         end
  151.        
  152.         function monitor.switch(mon, cc, ins, pos1, pos2, col1, col2, col3, text)
  153.             if mon == "db" then
  154.                 if data1 == nil then
  155.                     return nil
  156.                 else
  157.                     return data1[cc]
  158.                 end
  159.             end
  160.             if mon == "setdb" then
  161.                 if data1 == nil then
  162.                     return "no data to edit"
  163.                 else
  164.                     data1[cc] = ins
  165.                     return("value changed too "..type(ins))
  166.                 end
  167.             end
  168.             if ins[2] == mon then
  169.                 if ins ~= nil then
  170.                     local re = string.len(text)
  171.                     local m = peripheral.wrap(mon)
  172.                     if data1 == nil then
  173.                         data1 = {}
  174.                         for is = 0, 1000 do
  175.                             data1[is] = false
  176.                         end
  177.                     end
  178.                     local function ff()
  179.                         data1[cc] = not data1[cc]
  180.                     end
  181.                     if monitor.API(ins, pos1, pos2, string.len(text), 1) == true then
  182.                         ff()
  183.                     end
  184.                     local oldcol1 = m.getTextColor()
  185.                     local oldcol2 = m.getBackgroundColor()
  186.                     if data1[cc] == true then
  187.                         m.setBackgroundColor(colors[col2])
  188.                     else
  189.                         m.setBackgroundColor(colors[col1])
  190.                     end
  191.                     m.setCursorPos(pos1, pos2)
  192.                     m.setTextColor(colors[col3])
  193.                     m.write(text)
  194.                     m.setTextColor(oldcol1)
  195.                     m.setBackgroundColor(oldcol2)
  196.                     return (data1[cc])
  197.                 end
  198.             end
  199.         end
  200.        
  201.         function monitor.switchn(mon, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  202.             if mon == "db" then
  203.                 if data2 == nil then
  204.                     return nil
  205.                 else
  206.                     return data2[cc]
  207.                 end
  208.             end
  209.             if mon == "setdb" then
  210.                 if data2 == nil then
  211.                     return "no data to edit"
  212.                 else
  213.                     data2[cc] = ins
  214.                     return("value changed too "..type(ins))
  215.                 end
  216.             end
  217.        
  218.             if ins[2] == mon then
  219.                 if ins ~= nil then
  220.                     local re = string.len(text)
  221.                     if string.len(text) ~= string.len(text2) then
  222.                         if string.len(text) > string.len(text2) then
  223.                             re = string.len(text)
  224.                         else
  225.                             re = string.len(text2)
  226.                         end
  227.                     end
  228.                     local m = peripheral.wrap(mon)
  229.                     if data2 == nil then
  230.                         data2 = {}
  231.                         for is = 0, 1000 do
  232.                             data2[is] = false
  233.                         end
  234.                     end
  235.                     local function ff()
  236.                         data2[cc] = not data2[cc]
  237.                     end
  238.                     if monitor.API(ins, pos1, pos2, re, 1) == true then
  239.                         ff()
  240.                     end
  241.                     local oldcol1 = m.getTextColor()
  242.                     local oldcol2 = m.getBackgroundColor()
  243.                     if data2[cc] == true then
  244.                         m.setCursorPos(pos1, pos2)
  245.                         if string.len(text) ~= string.len(text2) then
  246.                             m.write(string.rep(" ", re))
  247.                         end
  248.                         m.setBackgroundColor(colors[col2])
  249.                         m.setCursorPos(pos1, pos2)
  250.                         m.setTextColor(colors[col3])
  251.                         m.write(text2)
  252.                     else
  253.                         m.setCursorPos(pos1, pos2)
  254.                         if string.len(text) ~= string.len(text2) then
  255.                             m.write(string.rep(" ", re))
  256.                         end
  257.                         m.setBackgroundColor(colors[col1])
  258.                         m.setCursorPos(pos1, pos2)
  259.                         m.setTextColor(colors[col3])
  260.                         m.write(text)
  261.                     end
  262.                     m.setTextColor(oldcol1)
  263.                     m.setBackgroundColor(oldcol2)
  264.                     return (data2[cc])
  265.                 end
  266.             end
  267.         end
  268.         -- bundle cable APIs for using main API with bundled cables
  269.         function monitor.bundle(side, color, state)
  270.             if (type(side) == "string") and (type(color) == "number") and (type(state) == "boolean") then
  271.                 if state == true then
  272.                     rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
  273.                 elseif state == false then
  274.                     rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
  275.                 end
  276.             else
  277.                 error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")
  278.             end
  279.         end
  280.        
  281.         function monitor.signal(side, ins, col, func)
  282.             if ins == "clear" then
  283.                 rs.setBundledOutput(side, 0)
  284.             else
  285.                 if func == true then
  286.                     if ins == "on" then
  287.                         ins = true
  288.                     end
  289.                     if ins == "nil" then
  290.                         ins = false
  291.                     end
  292.                 end
  293.                 if ins ~= nil then
  294.                     if ins == true then
  295.                         bundle(side, col, true)
  296.                     elseif ins == false then
  297.                         bundle(side, col, false)
  298.                     end
  299.                 end
  300.             end
  301.         end
  302.         -------------------------------------------------------------------------------------------------
  303.        
  304.         function monitor.sliderHor(mon, ins, cc, pos1, pos2, length, color1, textCol)
  305.             if mon == "db" then
  306.                 if data3 == nil then
  307.                     return nil
  308.                 else
  309.                     return data3[ins]
  310.                 end
  311.             end
  312.             if mon == "setdb" then
  313.                 if data3 == nil then
  314.                     return "no data to edit"
  315.                 else
  316.                     data3[ins] = cc
  317.                     return("value changed too "..type(cc))
  318.                 end
  319.             end
  320.             if ins[2] == mon then
  321.                 if ins ~= nil then
  322.                     m = peripheral.wrap(mon)
  323.                     local oldcol1 = m.getBackgroundColor()
  324.                     local oldcol2 = m.getTextColor()
  325.                     m.setBackgroundColor(colors[color1])
  326.                     m.setTextColor(colors[textCol])
  327.                     m.setCursorPos(pos1, pos2)
  328.                     for i = 0, length do
  329.                         m.write("-")
  330.                         m.setCursorPos(pos1 + i, pos2)
  331.                     end
  332.                     if data3 == nil then
  333.                         data3 = {}
  334.                         for is = 0, 1000 do
  335.                             data3[is] = 0
  336.                         end
  337.                     end
  338.                     local cp = (ins[3])
  339.                     if (ins[4] == pos2) and (ins[3] >= pos1) and (ins[3] <= (pos1 + length) - 1) then
  340.                         m.setCursorPos(cp, pos2)
  341.                         data3[cc] = cp
  342.                         m.write("|")
  343.                     else
  344.                         m.setCursorPos(data3[cc], pos2)
  345.                         m.write("|")
  346.                     end
  347.                     m.setBackgroundColor(oldcol1)
  348.                     m.setTextColor(oldcol2)
  349.                     if data3[cc] - pos1 >= 0 then
  350.                         return (data3[cc] - pos1)
  351.                     elseif data3[cc] - pos1 < 0 then
  352.                         return 0
  353.                     end
  354.                 end
  355.             end
  356.         end
  357.        
  358.         function monitor.sliderVer(mon, ins, cc, pos1, pos2, length, color1, textCol)
  359.             if mon == "db" then
  360.                 if data10 == nil then
  361.                     return nil
  362.                 else
  363.                     return data10[ins]
  364.                 end
  365.             end
  366.             if mon == "setdb" then
  367.                 if data10 == nil then
  368.                     return "no data to edit"
  369.                 else
  370.                     data10[ins] = cc
  371.                     return("value changed too "..type(cc))
  372.                 end
  373.             end
  374.             if ins[2] == mon then
  375.                 if ins ~= nil then
  376.                     m = peripheral.wrap(mon)
  377.                     local oldcol1 = m.getBackgroundColor()
  378.                     local oldcol2 = m.getTextColor()
  379.                     m.setBackgroundColor(colors[color1])
  380.                     m.setTextColor(colors[textCol])
  381.                     m.setCursorPos(pos1, pos2)
  382.                     for i = 0, length do
  383.                         m.write("\124")
  384.                         m.setCursorPos(pos1, pos2 - i)
  385.                     end
  386.                     if data10 == nil then
  387.                         data10 = {}
  388.                         for is = 0, 1000 do
  389.                             data10[is] = 0
  390.                         end
  391.                     end
  392.                     local cp = ins[4]
  393.                     if (ins[3] == pos1) and (ins[4] <= pos2) and (ins[4] >= (pos2 - length) + 1) then
  394.                         m.setCursorPos(pos1, cp)
  395.                         data10[cc] = cp
  396.                         m.write("\xad")
  397.                     else
  398.                         m.setCursorPos(pos1, data10[cc])
  399.                         m.write("\xad")
  400.                     end
  401.                     m.setBackgroundColor(oldcol1)
  402.                     m.setTextColor(oldcol2)
  403.                     if data10[cc] - pos1 >= 0 then
  404.                         return (data10[cc] - pos1)
  405.                     elseif data10[cc] - pos1 < 0 then
  406.                         return 0
  407.                     end
  408.                 end
  409.             end
  410.         end
  411.        
  412.         function monitor.render(mon, text, x, y, textcol, backCol)
  413.             local m = peripheral.wrap(mon)
  414.             local oldcol1 = m.getBackgroundColor()
  415.             local oldcol2 = m.getTextColor()
  416.             local cur = {m.getCursorPos()}
  417.             m.setTextColor(colors[textcol])
  418.             if type(backCol) == "string" then
  419.                 m.setBackgroundColor(colors[backCol])
  420.             elseif type(backCol) == "number" then
  421.                 m.setBackgroundColor(backCol)
  422.             end
  423.             m.setCursorPos(x, y)
  424.             m.write(text)
  425.             m.setBackgroundColor(oldcol1)
  426.             m.setTextColor(oldcol2)
  427.             m.setCursorPos(cur[1], cur[2])
  428.         end
  429.        
  430.         function monitor.menu(mon, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)
  431.             if ins[2] == mon then
  432.                 if thisIsUseless == nil then
  433.                     for i = 0, 1000 do
  434.                         thisIsUseless = {}
  435.                         thisIsUseless[i] = false
  436.                     end
  437.                 end
  438.                 if not thisIsUseless[cc] then
  439.                     monitor.render(mon, text, x, y, textcol, oldcol2)
  440.                 end
  441.                 if ins ~= nil then
  442.                     local m = peripheral.wrap(mon)
  443.                     local oldcol1 = m.getTextColor()
  444.                     local oldcol2 = m.getBackgroundColor()
  445.                     local l = string.len(text)
  446.                     if ins[1] ~= "timeout" then
  447.                         if data4 == nil then
  448.                             data4 = {}
  449.                             for is = 0, 1000 do
  450.                                 data4[is] = false
  451.                             end
  452.                         end
  453.                         if data5 == nil then
  454.                             data5 = {}
  455.                             for is = 0, 1000 do
  456.                                 data5[is] = false
  457.                             end
  458.                         end
  459.                         if data6 == nil then
  460.                             data6 = {}
  461.                             for is = 0, 1000 do
  462.                                 data6[is] = false
  463.                             end
  464.                         end
  465.                         if monitor.API(ins, x, y, l, 1) == true then
  466.                             data4[cc] = text
  467.                             data5[cc] = x
  468.                             data6[cc] = y
  469.                             local function menus()
  470.                                 for i = 1, 500 do
  471.                                     if data4[i] ~= false then
  472.                                         m.setBackgroundColor(oldcol2)
  473.                                         m.setCursorPos(data5[i], data6[i])
  474.                                         m.setTextColor(colors[textcol])
  475.                                         m.write(data4[i])
  476.                                     end
  477.                                 end
  478.                                 local i = 0
  479.                             end
  480.                             menus()
  481.                             m.setCursorPos(data5[cc], data6[cc])
  482.                             m.setBackgroundColor(colors[switchcol])
  483.                             m.setTextColor(colors[textcol])
  484.                             m.write(text)
  485.                             m.setTextColor(oldcol1)
  486.                             m.setBackgroundColor(oldcol2)
  487.                             menuout = text
  488.                             if returns1 == nil then
  489.                                 return menuout
  490.                             else
  491.                                 if (more == nil) or (more == false) then
  492.                                     menuout = returns1
  493.                                     return menuout
  494.                                 else
  495.                                     menuout = {
  496.                                         returns1,
  497.                                         returns2
  498.                                     }
  499.                                     if menuout == nil then
  500.                                         return 0
  501.                                     end
  502.                                     return menuout
  503.                                 end
  504.                             end
  505.                         end
  506.                     end
  507.                 end
  508.             end
  509.             thisIsUseless[cc] = true
  510.             if more == true then
  511.                 if menuout == nil then
  512.                     menuout = {returns1, "nil"}
  513.                 end
  514.             end
  515.         end
  516.        
  517.         function monitor.menudata()
  518.             if menuout ~= nil then
  519.                 return menuout
  520.             else
  521.                 return "no output"
  522.             end
  523.         end
  524.        
  525.         function monitor.timeswitch(mon, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  526.             if mon == "db" then
  527.                 if data7 == nil then
  528.                     return nil
  529.                 else
  530.                     return data7[ins]
  531.                 end
  532.             end
  533.             if mon == "setdb" then
  534.                 if data7 == nil then
  535.                     return "no data to edit"
  536.                 else
  537.                     data7[ins] = cc
  538.                     return("value changed too "..type(cc))
  539.                 end
  540.             end
  541.             if ins[2] == mon then
  542.                 if ins ~= nil then
  543.                     local m = peripheral.wrap(mon)
  544.                     local oldcol1 = m.getTextColor()
  545.                     local oldcol2 = m.getBackgroundColor()
  546.                     m.setBackgroundColor(colors[col2])
  547.                     m.setTextColor(colors[col1])
  548.                     if data7 == nil then
  549.                         data7 = {}
  550.                         for is = 0, 1000 do
  551.                             data7[is] = false
  552.                         end
  553.                     end
  554.                     if data8 == nil then
  555.                         data8 = {}
  556.                         for is = 0, 1000 do
  557.                             data8[is] = false
  558.                         end
  559.                     end
  560.                     if data8[cc] == false then
  561.                         data8[cc] = start
  562.                         m.setCursorPos(pos1 + 6, pos2)
  563.                         m.write(data8[cc])
  564.                     end
  565.                     m.setCursorPos(pos1, pos2)
  566.                     m.write("start")
  567.                     if monitor.API(ins, pos1, pos2, 4, 1) == true then
  568.                         data7[cc] = true
  569.                     end
  570.                     if data7[cc] == true then
  571.                         if data8[cc] > 0 then
  572.                             repeat
  573.                                 timeOut = data8[cc]
  574.                                 m.setBackgroundColor(colors[col3])
  575.                                 data8[cc] = data8[cc] - change
  576.                                 m.setCursorPos(pos1 + 6, pos2)
  577.                                 sleep(1)
  578.                                 m.write(data8[cc])
  579.                             until data8[cc] == 0
  580.                             return "ended"
  581.                         end
  582.                     end
  583.                     if repeats == true then
  584.                         data8[cc] = start
  585.                     end
  586.                     m.setBackgroundColor(colors[col2])
  587.                     m.setCursorPos(pos1 + 6, pos2)
  588.                     m.write(data8[cc])
  589.                     m.setTextColor(oldcol1)
  590.                     m.setBackgroundColor(oldcol2)
  591.                 end
  592.             end
  593.         end
  594.        
  595.         function monitor.bar(
  596.             mon,
  597.             pos1,
  598.             pos2,
  599.             length,
  600.             height,
  601.             ins,
  602.             max,
  603.             color1,
  604.             color2,
  605.             color3,
  606.             printval,
  607.             hor,
  608.             text,
  609.             format,
  610.             rect,
  611.             thicc)
  612.             if (ins == nil) or (ins < 0) then
  613.                 ins = 0
  614.             end
  615.             if format == nil then
  616.                 local format = false
  617.             end
  618.             if ins ~= nil then
  619.                 local m = peripheral.wrap(mon)
  620.                 oldcol = m.getBackgroundColor()
  621.                 oldcol1 = m.getTextColor()
  622.                 m.setTextColor(colors[color3])
  623.                 local function reprint()
  624.                     m.setBackgroundColor(colors[color1])
  625.                     monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  626.                     m.setBackgroundColor(oldcol)
  627.                     xm = m.getBackgroundColor()
  628.                     xb = m.getTextColor()
  629.                     m.setTextColor(xm)
  630.                     m.setBackgroundColor(xb)
  631.                     m.setCursorPos(pos1 - 1, pos2 - height)
  632.                     if thicc then
  633.                         m.setBackgroundColor(colors[color3])
  634.                     end
  635.                     if thicc then
  636.                         m.write(string.rep("\x83", length + 1)) --\143
  637.                         m.setTextColor(xb)
  638.                         m.setBackgroundColor(xm)
  639.                     else
  640.                         m.write("\159" .. string.rep("\143", length - 1)) --\x83
  641.                         m.setTextColor(xb)
  642.                         m.setBackgroundColor(xm)
  643.                         m.write("\144")
  644.                     end
  645.                     if thicc then
  646.                         m.setBackgroundColor(colors[color3])
  647.                     end
  648.                     m.setCursorPos(pos1 - 1, pos2 + height)
  649.                     if thicc then
  650.                         m.write(string.rep("\x8c", length + 1)) --\131
  651.                     else
  652.                         m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  653.                     end
  654.                     for i = 0, (height * 2) - 2 do
  655.                         if not thicc then
  656.                             m.setTextColor(xm)
  657.                             m.setBackgroundColor(xb)
  658.                         end
  659.                         m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  660.                         if thicc then
  661.                             m.setBackgroundColor(colors[color3])
  662.                         end
  663.                         m.write("\x95")
  664.                         m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  665.                         if not thicc then
  666.                             m.setTextColor(xb)
  667.                             m.setBackgroundColor(xm)
  668.                         end
  669.                         m.write("\x95")
  670.                     end
  671.                 end
  672.                 if rect ~= false then
  673.                     reprint()
  674.                 else
  675.                     monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  676.                 end
  677.                 local drawLength = ins / max * length
  678.                 local drawHeights = ins / max * height
  679.                 local drawHeight = math.ceil(drawHeights)
  680.                 local moveval = (drawHeight * 2) - 2
  681.                 local z = pos2 + height
  682.                 m.setBackgroundColor(colors[color2])
  683.                 if (hor == false) or (hor == nil) then
  684.                     monitor.fill(mon, pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  685.                 else
  686.                     monitor.fill(mon, pos1, (z - 1) - moveval, length - 1, moveval + 1)
  687.                 end
  688.                 if printval == true then
  689.                     m.setCursorPos(pos1, pos2)
  690.                     m.setTextColor(colors[color3])
  691.                     if hor == true then
  692.                         if format then
  693.                             if ins >= max / 2 then
  694.                                 m.setBackgroundColor(colors[color2])
  695.                             else
  696.                                 m.setBackgroundColor(colors[color1])
  697.                             end
  698.                         else
  699.                             if ins >= (max / 2) - (max / height) then
  700.                                 m.setBackgroundColor(colors[color2])
  701.                             else
  702.                                 m.setBackgroundColor(colors[color1])
  703.                             end
  704.                         end
  705.                     elseif hor == false then
  706.                         m.setCursorPos(pos1, pos2)
  707.                         m.setTextColor(colors[color3])
  708.                         if hor == true then
  709.                             if ins >= 1 then
  710.                                 m.setBackgroundColor(colors[color2])
  711.                             else
  712.                                 m.setBackgroundColor(colors[color1])
  713.                             end
  714.                         end
  715.                     end
  716.                     if format then
  717.                         m.write(ins .. "/" .. max)
  718.                         m.setCursorPos(pos1, pos2 + 1)
  719.                         m.write(text)
  720.                     else
  721.                         m.write(ins .. "/" .. max .. " " .. text)
  722.                     end
  723.                     m.setBackgroundColor(oldcol)
  724.                     m.setTextColor(oldcol1)
  725.                 end
  726.                 m.setTextColor(oldcol1)
  727.                 m.setBackgroundColor(oldcol)
  728.             end
  729.         end
  730.    
  731.         function monitor.frame(mon, pos1, pos2, length, height, color3, color1, thicc)
  732.             local m = peripheral.wrap(mon)
  733.             local oldcol = m.getBackgroundColor()
  734.             local oldcol1 = m.getTextColor()
  735.             m.setBackgroundColor(colors[color1])
  736.             monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  737.             m.setBackgroundColor(oldcol)
  738.             xm = m.getBackgroundColor()
  739.             xb = m.getTextColor()
  740.             m.setTextColor(xm)
  741.             m.setBackgroundColor(xb)
  742.             m.setCursorPos(pos1 - 1, pos2 - height)
  743.             if thicc then
  744.                 m.setBackgroundColor(colors[color3])
  745.                 m.setTextColor(oldcol)
  746.                 m.write(string.rep("\x83", length + 1)) --\143
  747.                 m.setTextColor(xb)
  748.                 m.setBackgroundColor(xm)
  749.             else
  750.                 m.setTextColor(oldcol)
  751.                 m.setBackgroundColor(colors[color3])
  752.                 m.write("\159" .. string.rep("\143", length - 1)) --\x83
  753.                 m.setTextColor(colors[color3])
  754.                 m.setBackgroundColor(oldcol)
  755.                 m.write("\144")
  756.             end
  757.             m.setCursorPos(pos1 - 1, pos2 + height)
  758.             if thicc then
  759.                 m.setBackgroundColor(oldcol)
  760.                 m.setTextColor(colors[color3])
  761.                 m.write(string.rep("\x8f", length + 1)) --\131
  762.                 m.setBackgroundColor(colors[color1])
  763.                 m.setTextColor(colors[color3])
  764.             else
  765.                 m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  766.             end
  767.             for i = 0, (height * 2) - 2 do
  768.                 if not thicc then
  769.                     m.setTextColor(xm)
  770.                     m.setBackgroundColor(xb)
  771.                 end
  772.                 m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  773.                 if thicc then
  774.                     m.setBackgroundColor(colors[color3])
  775.                 end
  776.                 m.setBackgroundColor(colors[color3])
  777.                 m.write("\x95")
  778.                 m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  779.                 if not thicc then
  780.                     m.setTextColor(xb)
  781.                     m.setBackgroundColor(xm)
  782.                 end
  783.                 m.setTextColor(colors[color3])
  784.                 m.write("\x95")
  785.             end
  786.             m.setBackgroundColor(oldcol)
  787.             m.setTextColor(oldcol1)
  788.         end
  789.        
  790.         return {
  791.             monitor = monitor,
  792.         }
  793.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement