9551

LTDZZZEJ backup

Jul 3rd, 2021 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 59.23 KB | None | 0 0
  1. --------------------Buttonh----------------------------
  2. ----------------------MENU/PANEL API-------------------
  3. --------------------by 9551 DEV!--------------------
  4. ---Copyright (c) 2021-2022 9551------------9551#0001---
  5. ---using this code in your project is fine!------------
  6. ---as long as you dont claim you made it---------------
  7. ---im cool with it, feel free to include---------------
  8. ---in your projects!   discord: 9551#0001--------------
  9. ---you dont have to but giving credits is nice :)------
  10. -------------------------------------------------------
  11. -------------------------------------------------------
  12. --*!   pastebin get LTDZZZEJ button
  13.  
  14. --*functions usages
  15. --*API(ins, cord1, cord2, length, height)
  16. --*timetouch(timeout,monitor)
  17. --*touch()
  18. --*button(monitor, ins, cord1, cord2, text)
  19. --*counter(monitor, ins, cc, cord1, cord2, cv, max, min, col)
  20. --*fill(monitor, pos1, pos2, length, height)
  21. --*switch(monitor, ccins, pos1, pos2, col1, col2, col3, text)
  22. --*switchn(monitor, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  23. --*bundle(side, color, state)
  24. --*signal(side, ins, col)
  25. --*sliderVer/Hor(monitor, ins, cc, pos1, pos2, length, color1, textCol)
  26. --*local function menu(monitor, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)  (returns menuout)
  27. --*bar(monitor, pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
  28. --*timeswitch(monitor, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  29. --*render(monitor,text,x,y,textcol,backCol)
  30. --*menudata()
  31. --*frame(monitor, pos1, pos2, length, height, color3, color1, thicc)
  32. --*db allows you to get stored data from all functions that use stored data!
  33. --*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
  34.  
  35. --base API this API is made for detecting clicks in an area
  36. local monitor = {}
  37. local terminal = {}
  38. local expect = require("cc.expect").expect
  39. function monitor.API(ins, cord1, cord2, length, height)
  40.     expect(1, ins, "table")
  41.     expect(2, cord1, "number")
  42.     expect(3, cord2, "number")
  43.     expect(4, length, "number")
  44.     expect(5, height, "number")
  45.     if ins == true then
  46.         ins = {os.pullEvent("monitor_touch")}
  47.     end
  48.     if ins[3] >= cord1 and ins[3] <= cord1 + length - 1 then
  49.         if ins[4] >= cord2 and ins[4] <= cord2 + height - 1 then
  50.             return true
  51.         else
  52.             return false
  53.         end
  54.     end
  55. end
  56.  
  57. function monitor.touch()
  58.     local dats = {os.pullEvent("monitor_touch")}
  59.     return dats
  60. end
  61.  
  62. function monitor.timetouch(timeout, mon)
  63.     expect(1, timeout, "number")
  64.     expect(2, mon, "string")
  65.     local timer = os.startTimer(timeout)
  66.     while true do
  67.         local event = {os.pullEvent()}
  68.         if (event[1] == "timer") and (event[2] == timer) then
  69.             if mon == nil then
  70.                 local mon = "timeout"
  71.             end
  72.             return {"timeout", mon, 1000, 1000}
  73.         elseif (event[1] == "monitor_touch") and (event[2] == mon) then
  74.             return {event[1], event[2], event[3], event[4]}
  75.         end
  76.     end
  77. end
  78.  
  79. -------------------------------------------------------------------------------------------------
  80.  
  81. function monitor.button(mon, ins, cord1, cord2, text)
  82.     expect(1, mon, "string")
  83.     expect(2, ins, "table")
  84.     expect(3, cord1, "number")
  85.     expect(4, cord2, "number")
  86.     expect(5, text, "string")
  87.     if ins[2] == mon then
  88.         if ins ~= nil then
  89.             local m = peripheral.wrap(mon)
  90.             local x = monitor.API(ins, cord1, cord2, string.len(text), 1)
  91.             m.setCursorPos(cord1, cord2)
  92.             m.write(text)
  93.             return x
  94.         end
  95.     end
  96. end
  97.  
  98. function monitor.counter(mon, ins, cc, cord1, cord2, cv, max, min, col)
  99.     if mon == "db" then
  100.         if data == nil then
  101.             return nil
  102.         else
  103.             return data[ins]
  104.         end
  105.     end
  106.     if mon == "setdb" then
  107.         if data == nil then
  108.             return "no data to edit"
  109.         else
  110.             data[ins] = cc
  111.             return ("value changed too " .. type(cc))
  112.         end
  113.     end
  114.     expect(1, mon, "string")
  115.     expect(2, ins, "table")
  116.     expect(3, cc, "number")
  117.     expect(4, cord1, "number")
  118.     expect(5, cord2, "number")
  119.     expect(6, cv, "number")
  120.     expect(7, max, "number")
  121.     expect(8, min, "number")
  122.     expect(9, col, "string")
  123.     if ins[2] == mon then
  124.         if ins ~= nil then
  125.             local m = peripheral.wrap(mon)
  126.             if data == nil then
  127.                 data = {}
  128.                 for is = 0, 1000 do
  129.                     data[is] = 0
  130.                 end
  131.             end
  132.             m.setCursorPos(cord1, cord2)
  133.             m.write("\24" .. " " .. data[cc])
  134.             m.setCursorPos(cord1, cord2 + 1)
  135.             m.write("\25")
  136.             if monitor.API(ins, cord1, cord2, 1, 1) == true then
  137.                 if data[cc] < max then
  138.                     data[cc] = data[cc] + cv
  139.                     m.setCursorPos(cord1, cord2)
  140.                     m.setTextColor(colors.green)
  141.                     m.write("\24" .. " " .. data[cc] .. " ")
  142.                     m.setCursorPos(cord1, cord2 + 1)
  143.                     m.setTextColor(colors.red)
  144.                     m.write("\25")
  145.                     m.setTextColor(colors[col])
  146.                     return data[cc]
  147.                 end
  148.             end
  149.         end
  150.         if monitor.API(ins, cord1, cord2 + 1, 1, 1) == true then
  151.             if data[cc] > min then
  152.                 data[cc] = data[cc] - cv
  153.                 m.setCursorPos(cord1, cord2)
  154.                 m.setTextColor(colors.green)
  155.                 m.write("\24" .. " " .. data[cc] .. " ")
  156.                 m.setCursorPos(cord1, cord2 + 1)
  157.                 m.setTextColor(colors.red)
  158.                 m.write("\25")
  159.                 m.setTextColor(colors[col])
  160.                 return data[cc]
  161.             end
  162.         end
  163.     end
  164. end
  165.  
  166. function monitor.fill(mon, pos1, pos2, length, height)
  167.     expect(1, mon, "string")
  168.     expect(2, pos1, "number")
  169.     expect(3, pos2, "number")
  170.     expect(4, length, "number")
  171.     expect(5, height, "number")
  172.     local m = peripheral.wrap(mon)
  173.     for x = 0, height - 1 do
  174.         m.setCursorPos(pos1, pos2 + x)
  175.         m.write(string.rep(" ", length))
  176.     end
  177. end
  178.  
  179. function monitor.switch(mon, cc, ins, pos1, pos2, col1, col2, col3, text)
  180.     if mon == "db" then
  181.         if data1 == nil then
  182.             return nil
  183.         else
  184.             return data1[cc]
  185.         end
  186.     end
  187.     if mon == "setdb" then
  188.         if data1 == nil then
  189.             return "no data to edit"
  190.         else
  191.             data1[cc] = ins
  192.             return ("value changed too " .. type(ins))
  193.         end
  194.     end
  195.     expect(1, mon, "string")
  196.     expect(2, cc, "number")
  197.     expect(3, ins, "table")
  198.     expect(4, pos1, "number")
  199.     expect(5, pos2, "number")
  200.     expect(6, col1, "string")
  201.     expect(7, col2, "string")
  202.     expect(8, col3, "string")
  203.     expect(9, text, "string")
  204.     if ins[2] == mon then
  205.         if ins ~= nil then
  206.             local re = string.len(text)
  207.             local m = peripheral.wrap(mon)
  208.             if data1 == nil then
  209.                 data1 = {}
  210.                 for is = 0, 1000 do
  211.                     data1[is] = false
  212.                 end
  213.             end
  214.             local function ff()
  215.                 data1[cc] = not data1[cc]
  216.             end
  217.             if monitor.API(ins, pos1, pos2, string.len(text), 1) == true then
  218.                 ff()
  219.             end
  220.             local oldcol1 = m.getTextColor()
  221.             local oldcol2 = m.getBackgroundColor()
  222.             if data1[cc] == true then
  223.                 m.setBackgroundColor(colors[col2])
  224.             else
  225.                 m.setBackgroundColor(colors[col1])
  226.             end
  227.             m.setCursorPos(pos1, pos2)
  228.             m.setTextColor(colors[col3])
  229.             m.write(text)
  230.             m.setTextColor(oldcol1)
  231.             m.setBackgroundColor(oldcol2)
  232.             return (data1[cc])
  233.         end
  234.     end
  235. end
  236.  
  237. function monitor.switchn(mon, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  238.     if mon == "db" then
  239.         if data2 == nil then
  240.             return nil
  241.         else
  242.             return data2[cc]
  243.         end
  244.     end
  245.     if mon == "setdb" then
  246.         if data2 == nil then
  247.             return "no data to edit"
  248.         else
  249.             data2[cc] = ins
  250.             return ("value changed too " .. type(ins))
  251.         end
  252.     end
  253.     expect(1, mon, "string")
  254.     expect(2, cc, "number")
  255.     expect(3, ins, "table")
  256.     expect(4, pos1, "number")
  257.     expect(5, pos2, "number")
  258.     expect(6, col1, "string")
  259.     expect(7, col2, "string")
  260.     expect(8, col3, "string")
  261.     expect(9, text, "string")
  262.     expect(10, text2, "string")
  263.  
  264.     if ins[2] == mon then
  265.         if ins ~= nil then
  266.             local re = string.len(text)
  267.             if string.len(text) ~= string.len(text2) then
  268.                 if string.len(text) > string.len(text2) then
  269.                     re = string.len(text)
  270.                 else
  271.                     re = string.len(text2)
  272.                 end
  273.             end
  274.             local m = peripheral.wrap(mon)
  275.             if data2 == nil then
  276.                 data2 = {}
  277.                 for is = 0, 1000 do
  278.                     data2[is] = false
  279.                 end
  280.             end
  281.             local function ff()
  282.                 data2[cc] = not data2[cc]
  283.             end
  284.             if monitor.API(ins, pos1, pos2, re, 1) == true then
  285.                 ff()
  286.             end
  287.             local oldcol1 = m.getTextColor()
  288.             local oldcol2 = m.getBackgroundColor()
  289.             if data2[cc] == true then
  290.                 m.setCursorPos(pos1, pos2)
  291.                 if string.len(text) ~= string.len(text2) then
  292.                     m.write(string.rep(" ", re))
  293.                 end
  294.                 m.setBackgroundColor(colors[col2])
  295.                 m.setCursorPos(pos1, pos2)
  296.                 m.setTextColor(colors[col3])
  297.                 m.write(text2)
  298.             else
  299.                 m.setCursorPos(pos1, pos2)
  300.                 if string.len(text) ~= string.len(text2) then
  301.                     m.write(string.rep(" ", re))
  302.                 end
  303.                 m.setBackgroundColor(colors[col1])
  304.                 m.setCursorPos(pos1, pos2)
  305.                 m.setTextColor(colors[col3])
  306.                 m.write(text)
  307.             end
  308.             m.setTextColor(oldcol1)
  309.             m.setBackgroundColor(oldcol2)
  310.             return (data2[cc])
  311.         end
  312.     end
  313. end
  314. -- bundle cable APIs for using main API with bundled cables
  315. function monitor.bundle(side, color, state)
  316.     expect(1, side, "string")
  317.     expect(2, color, "number")
  318.     expect(3, state, "boolean")
  319.     if state == true then
  320.         rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
  321.     elseif state == false then
  322.         rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
  323.     end
  324. end
  325.  
  326. function monitor.signal(side, ins, col, func)
  327.     expect(1, side, "string")
  328.     expect(2, ins, "boolean", "string")
  329.     expect(3, col, "number")
  330.     expect(4, func, "boolean")
  331.     if ins == "clear" then
  332.         rs.setBundledOutput(side, 0)
  333.     else
  334.         if func == true then
  335.             if ins == "on" then
  336.                 ins = true
  337.             end
  338.             if ins == "nil" then
  339.                 ins = false
  340.             end
  341.         end
  342.         if ins ~= nil then
  343.             if ins == true then
  344.                 bundle(side, col, true)
  345.             elseif ins == false then
  346.                 bundle(side, col, false)
  347.             end
  348.         end
  349.     end
  350. end
  351. -------------------------------------------------------------------------------------------------
  352.  
  353. function monitor.sliderHor(mon, ins, cc, pos1, pos2, length, color1, textCol)
  354.     if mon == "db" then
  355.         if data3 == nil then
  356.             return nil
  357.         else
  358.             return data3[ins]
  359.         end
  360.     end
  361.     if mon == "setdb" then
  362.         if data3 == nil then
  363.             return "no data to edit"
  364.         else
  365.             data3[ins] = cc
  366.             return ("value changed too " .. type(cc))
  367.         end
  368.     end
  369.     expect(1, mon, "string")
  370.     expect(2, ins, "table")
  371.     expect(3, cc, "number")
  372.     expect(4, pos1, "number")
  373.     expect(5, pos2, "number")
  374.     expect(6, length, "number")
  375.     expect(7, color1, "string")
  376.     expect(8, textCol, "string")
  377.     if ins[2] == mon then
  378.         if ins ~= nil then
  379.             m = peripheral.wrap(mon)
  380.             local oldcol1 = m.getBackgroundColor()
  381.             local oldcol2 = m.getTextColor()
  382.             m.setBackgroundColor(colors[color1])
  383.             m.setTextColor(colors[textCol])
  384.             m.setCursorPos(pos1, pos2)
  385.             for i = 0, length do
  386.                 m.write("-")
  387.                 m.setCursorPos(pos1 + i, pos2)
  388.             end
  389.             if data3 == nil then
  390.                 data3 = {}
  391.                 for is = 0, 1000 do
  392.                     data3[is] = 0
  393.                 end
  394.             end
  395.             local cp = (ins[3])
  396.             if (ins[4] == pos2) and (ins[3] >= pos1) and (ins[3] <= (pos1 + length) - 1) then
  397.                 m.setCursorPos(cp, pos2)
  398.                 data3[cc] = cp
  399.                 m.write("|")
  400.             else
  401.                 m.setCursorPos(data3[cc], pos2)
  402.                 m.write("|")
  403.             end
  404.             m.setBackgroundColor(oldcol1)
  405.             m.setTextColor(oldcol2)
  406.             if data3[cc] - pos1 >= 0 then
  407.                 return (data3[cc] - pos1)
  408.             elseif data3[cc] - pos1 < 0 then
  409.                 return 0
  410.             end
  411.         end
  412.     end
  413. end
  414.  
  415. function monitor.sliderVer(mon, ins, cc, pos1, pos2, length, color1, textCol)
  416.     if mon == "db" then
  417.         if data10 == nil then
  418.             return nil
  419.         else
  420.             return data10[ins]
  421.         end
  422.     end
  423.     if mon == "setdb" then
  424.         if data10 == nil then
  425.             return "no data to edit"
  426.         else
  427.             data10[ins] = cc
  428.             return ("value changed too " .. type(cc))
  429.         end
  430.     end
  431.     expect(1, mon, "string")
  432.     expect(2, ins, "table")
  433.     expect(3, cc, "number")
  434.     expect(4, pos1, "number")
  435.     expect(5, pos2, "number")
  436.     expect(6, length, "number")
  437.     expect(7, color1, "string")
  438.     expect(8, textCol, "string")
  439.     if ins[2] == mon then
  440.         if ins ~= nil then
  441.             m = peripheral.wrap(mon)
  442.             local oldcol1 = m.getBackgroundColor()
  443.             local oldcol2 = m.getTextColor()
  444.             m.setBackgroundColor(colors[color1])
  445.             m.setTextColor(colors[textCol])
  446.             m.setCursorPos(pos1, pos2)
  447.             for i = 0, length do
  448.                 m.write("\124")
  449.                 m.setCursorPos(pos1, pos2 - i)
  450.             end
  451.             if data10 == nil then
  452.                 data10 = {}
  453.                 for is = 0, 1000 do
  454.                     data10[is] = 0
  455.                 end
  456.             end
  457.             local cp = ins[4]
  458.             if (ins[3] == pos1) and (ins[4] <= pos2) and (ins[4] >= (pos2 - length) + 1) then
  459.                 m.setCursorPos(pos1, cp)
  460.                 data10[cc] = cp
  461.                 m.write("\xad")
  462.             else
  463.                 m.setCursorPos(pos1, data10[cc])
  464.                 m.write("\xad")
  465.             end
  466.             m.setBackgroundColor(oldcol1)
  467.             m.setTextColor(oldcol2)
  468.             if data10[cc] - pos1 >= 0 then
  469.                 return (data10[cc] - pos1)
  470.             elseif data10[cc] - pos1 < 0 then
  471.                 return 0
  472.             end
  473.         end
  474.     end
  475. end
  476.  
  477. function monitor.render(mon, text, x, y, textcol, backCol)
  478.     expect(1, mon, "string")
  479.     expect(2, text, "string")
  480.     expect(3, x, "number")
  481.     expect(4, y, "number")
  482.     expect(5, textcol, "string")
  483.     expect(6, backCol, "string", "number")
  484.     local m = peripheral.wrap(mon)
  485.     local oldcol1 = m.getBackgroundColor()
  486.     local oldcol2 = m.getTextColor()
  487.     local cur = {m.getCursorPos()}
  488.     m.setTextColor(colors[textcol])
  489.     if type(backCol) == "string" then
  490.         m.setBackgroundColor(colors[backCol])
  491.     elseif type(backCol) == "number" then
  492.         m.setBackgroundColor(backCol)
  493.     end
  494.     m.setCursorPos(x, y)
  495.     m.write(text)
  496.     m.setBackgroundColor(oldcol1)
  497.     m.setTextColor(oldcol2)
  498.     m.setCursorPos(cur[1], cur[2])
  499. end
  500.  
  501. function monitor.menu(mon, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)
  502.     expect(1, mon, "string")
  503.     expect(2, ins, "table")
  504.     expect(3, cc, "number")
  505.     expect(4, x, "number")
  506.     expect(5, y, "number")
  507.     expect(6, textcol, "string")
  508.     expect(7, switchcol, "string")
  509.     expect(8, text, "string")
  510.     expect(9, returns1, "string", "number", "boolean", "nil")
  511.     expect(10, more, "boolean")
  512.     expect(11, returns2, "string", "number", "boolean", "nil")
  513.     if ins[2] == mon then
  514.         if thisIsUseless == nil then
  515.             for i = 0, 1000 do
  516.                 thisIsUseless = {}
  517.                 thisIsUseless[i] = false
  518.             end
  519.         end
  520.         if not thisIsUseless[cc] then
  521.             if textcol2 ~= nil then
  522.                 monitor.render(mon, text, x, y, textcol, oldcol2)
  523.             end
  524.         end
  525.         if ins ~= nil then
  526.             local m = peripheral.wrap(mon)
  527.             local oldcol1 = m.getTextColor()
  528.             local oldcol2 = m.getBackgroundColor()
  529.             local l = string.len(text)
  530.             if ins[1] ~= "timeout" then
  531.                 if data4 == nil then
  532.                     data4 = {}
  533.                     for is = 0, 1000 do
  534.                         data4[is] = false
  535.                     end
  536.                 end
  537.                 if data5 == nil then
  538.                     data5 = {}
  539.                     for is = 0, 1000 do
  540.                         data5[is] = false
  541.                     end
  542.                 end
  543.                 if data6 == nil then
  544.                     data6 = {}
  545.                     for is = 0, 1000 do
  546.                         data6[is] = false
  547.                     end
  548.                 end
  549.                 if monitor.API(ins, x, y, l, 1) == true then
  550.                     data4[cc] = text
  551.                     data5[cc] = x
  552.                     data6[cc] = y
  553.                     local function menus()
  554.                         for i = 1, 500 do
  555.                             if data4[i] ~= false then
  556.                                 m.setBackgroundColor(oldcol2)
  557.                                 m.setCursorPos(data5[i], data6[i])
  558.                                 m.setTextColor(colors[textcol])
  559.                                 m.write(data4[i])
  560.                             end
  561.                         end
  562.                         local i = 0
  563.                     end
  564.                     menus()
  565.                     m.setCursorPos(data5[cc], data6[cc])
  566.                     m.setBackgroundColor(colors[switchcol])
  567.                     m.setTextColor(colors[textcol])
  568.                     m.write(text)
  569.                     m.setTextColor(oldcol1)
  570.                     m.setBackgroundColor(oldcol2)
  571.                     menuout = text
  572.                     if returns1 == nil then
  573.                         return menuout
  574.                     else
  575.                         if (more == nil) or (more == false) then
  576.                             menuout = returns1
  577.                             return menuout
  578.                         else
  579.                             menuout = {
  580.                                 returns1,
  581.                                 returns2
  582.                             }
  583.                             if menuout == nil then
  584.                                 return 0
  585.                             end
  586.                             return menuout
  587.                         end
  588.                     end
  589.                 end
  590.             end
  591.         end
  592.     end
  593.     thisIsUseless[cc] = true
  594.     if more == true then
  595.         if menuout == nil then
  596.             menuout = {returns1, "nil"}
  597.         end
  598.     end
  599. end
  600.  
  601. function monitor.menudata()
  602.     if menuout ~= nil then
  603.         return menuout
  604.     else
  605.         return "no output"
  606.     end
  607. end
  608.  
  609. function monitor.timeswitch(mon, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  610.     if mon == "db" then
  611.         if data7 == nil then
  612.             return nil
  613.         else
  614.             return data7[ins]
  615.         end
  616.     end
  617.     if mon == "setdb" then
  618.         if data7 == nil then
  619.             return "no data to edit"
  620.         else
  621.             data7[ins] = cc
  622.             return ("value changed too " .. type(cc))
  623.         end
  624.     end
  625.     expect(1, mon, "string")
  626.     expect(2, ins, "table")
  627.     expect(3, cc, "number")
  628.     expect(4, pos1, "number")
  629.     expect(5, pos2, "number")
  630.     expect(6, change, "number")
  631.     expect(7, start, "number")
  632.     expect(8, col1, "string")
  633.     expect(9, col2, "string")
  634.     expect(10, col3, "string")
  635.     expect(11, repeats, "boolean")
  636.     if ins[2] == mon then
  637.         if ins ~= nil then
  638.             local m = peripheral.wrap(mon)
  639.             local oldcol1 = m.getTextColor()
  640.             local oldcol2 = m.getBackgroundColor()
  641.             m.setBackgroundColor(colors[col2])
  642.             m.setTextColor(colors[col1])
  643.             if data7 == nil then
  644.                 data7 = {}
  645.                 for is = 0, 1000 do
  646.                     data7[is] = false
  647.                 end
  648.             end
  649.             if data8 == nil then
  650.                 data8 = {}
  651.                 for is = 0, 1000 do
  652.                     data8[is] = false
  653.                 end
  654.             end
  655.             if data8[cc] == false then
  656.                 data8[cc] = start
  657.                 m.setCursorPos(pos1 + 6, pos2)
  658.                 m.write(data8[cc])
  659.             end
  660.             m.setCursorPos(pos1, pos2)
  661.             m.write("start")
  662.             if monitor.API(ins, pos1, pos2, 4, 1) == true then
  663.                 data7[cc] = true
  664.             end
  665.             if data7[cc] == true then
  666.                 if data8[cc] > 0 then
  667.                     repeat
  668.                         timeOut = data8[cc]
  669.                         m.setBackgroundColor(colors[col3])
  670.                         data8[cc] = data8[cc] - change
  671.                         m.setCursorPos(pos1 + 6, pos2)
  672.                         sleep(1)
  673.                         m.write(data8[cc])
  674.                     until data8[cc] == 0
  675.                     return "ended"
  676.                 end
  677.             end
  678.             if repeats == true then
  679.                 data8[cc] = start
  680.             end
  681.             m.setBackgroundColor(colors[col2])
  682.             m.setCursorPos(pos1 + 6, pos2)
  683.             m.write(data8[cc])
  684.             m.setTextColor(oldcol1)
  685.             m.setBackgroundColor(oldcol2)
  686.         end
  687.     end
  688. end
  689.  
  690. function monitor.bar(
  691.     mon,
  692.     pos1,
  693.     pos2,
  694.     length,
  695.     height,
  696.     ins,
  697.     max,
  698.     color1,
  699.     color2,
  700.     color3,
  701.     printval,
  702.     hor,
  703.     text,
  704.     format,
  705.     rect,
  706.     thicc)
  707.     expect(1, mon, "string")
  708.     expect(2, pos1, "number")
  709.     expect(3, pos2, "number")
  710.     expect(4, length, "number")
  711.     expect(5, height, "number")
  712.     expect(6, ins, "number")
  713.     expect(7, max, "number")
  714.     expect(8, color1, "string")
  715.     expect(9, color2, "string")
  716.     expect(10, color3, "string")
  717.     expect(11, printval, "boolean")
  718.     expect(12, hor, "boolean")
  719.     expect(13, text, "string")
  720.     expect(14, format, "boolean")
  721.     expect(15, rect, "boolean")
  722.     expect(16, thicc, "boolean")
  723.     if (ins == nil) or (ins < 0) then
  724.         ins = 0
  725.     end
  726.     if format == nil then
  727.         local format = false
  728.     end
  729.     if ins ~= nil then
  730.         local m = peripheral.wrap(mon)
  731.         oldcol = m.getBackgroundColor()
  732.         oldcol1 = m.getTextColor()
  733.         m.setTextColor(colors[color3])
  734.         local function reprint()
  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.             end
  746.             if thicc then
  747.                 m.write(string.rep("\x83", length + 1)) --\143
  748.                 m.setTextColor(xb)
  749.                 m.setBackgroundColor(xm)
  750.             else
  751.                 m.write("\159" .. string.rep("\143", length - 1)) --\x83
  752.                 m.setTextColor(xb)
  753.                 m.setBackgroundColor(xm)
  754.                 m.write("\144")
  755.             end
  756.             if thicc then
  757.                 m.setBackgroundColor(colors[color3])
  758.             end
  759.             m.setCursorPos(pos1 - 1, pos2 + height)
  760.             if thicc then
  761.                 m.write(string.rep("\x8c", length + 1)) --\131
  762.             else
  763.                 m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  764.             end
  765.             for i = 0, (height * 2) - 2 do
  766.                 if not thicc then
  767.                     m.setTextColor(xm)
  768.                     m.setBackgroundColor(xb)
  769.                 end
  770.                 m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  771.                 if thicc then
  772.                     m.setBackgroundColor(colors[color3])
  773.                 end
  774.                 m.write("\x95")
  775.                 m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  776.                 if not thicc then
  777.                     m.setTextColor(xb)
  778.                     m.setBackgroundColor(xm)
  779.                 end
  780.                 m.write("\x95")
  781.             end
  782.         end
  783.         if rect ~= false then
  784.             reprint()
  785.         else
  786.             monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  787.         end
  788.         local drawLength = ins / max * length
  789.         local drawHeights = ins / max * height
  790.         local drawHeight = math.ceil(drawHeights)
  791.         local moveval = (drawHeight * 2) - 2
  792.         local z = pos2 + height
  793.         m.setBackgroundColor(colors[color2])
  794.         if (hor == false) or (hor == nil) then
  795.             monitor.fill(mon, pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  796.         else
  797.             monitor.fill(mon, pos1, (z - 1) - moveval, length - 1, moveval + 1)
  798.         end
  799.         if printval == true then
  800.             m.setCursorPos(pos1, pos2)
  801.             m.setTextColor(colors[color3])
  802.             if hor == true then
  803.                 if format then
  804.                     if ins >= max / 2 then
  805.                         m.setBackgroundColor(colors[color2])
  806.                     else
  807.                         m.setBackgroundColor(colors[color1])
  808.                     end
  809.                 else
  810.                     if ins >= (max / 2) - (max / height) then
  811.                         m.setBackgroundColor(colors[color2])
  812.                     else
  813.                         m.setBackgroundColor(colors[color1])
  814.                     end
  815.                 end
  816.             elseif hor == false then
  817.                 m.setCursorPos(pos1, pos2)
  818.                 m.setTextColor(colors[color3])
  819.                 if hor == true then
  820.                     if ins >= 1 then
  821.                         m.setBackgroundColor(colors[color2])
  822.                     else
  823.                         m.setBackgroundColor(colors[color1])
  824.                     end
  825.                 end
  826.             end
  827.             if format then
  828.                 m.write(ins .. "/" .. max)
  829.                 m.setCursorPos(pos1, pos2 + 1)
  830.                 m.write(text)
  831.             else
  832.                 m.write(ins .. "/" .. max .. " " .. text)
  833.             end
  834.             m.setBackgroundColor(oldcol)
  835.             m.setTextColor(oldcol1)
  836.         end
  837.         m.setTextColor(oldcol1)
  838.         m.setBackgroundColor(oldcol)
  839.     end
  840. end
  841.  
  842. function monitor.frame(mon, pos1, pos2, length, height, color3, color1, thicc)
  843.     expect(1, mon, "string")
  844.     expect(2, pos1, "number")
  845.     expect(3, pos2, "number")
  846.     expect(4, length, "number")
  847.     expect(5, height, "number")
  848.     expect(6, color3, "string")
  849.     expect(7, color1, "string")
  850.     expect(8, thicc, "boolean", "nil")
  851.     local m = peripheral.wrap(mon)
  852.     local oldcol = m.getBackgroundColor()
  853.     local oldcol1 = m.getTextColor()
  854.     m.setBackgroundColor(colors[color1])
  855.     monitor.fill(mon, pos1 - 1, pos2 - height, length, height * 2)
  856.     m.setBackgroundColor(oldcol)
  857.     xm = m.getBackgroundColor()
  858.     xb = m.getTextColor()
  859.     m.setTextColor(xm)
  860.     m.setBackgroundColor(xb)
  861.     m.setCursorPos(pos1 - 1, pos2 - height)
  862.     if thicc then
  863.         m.setBackgroundColor(colors[color3])
  864.         m.setTextColor(oldcol)
  865.         m.write(string.rep("\x83", length + 1)) --\143
  866.         m.setTextColor(xb)
  867.         m.setBackgroundColor(xm)
  868.     else
  869.         m.setTextColor(oldcol)
  870.         m.setBackgroundColor(colors[color3])
  871.         m.write("\159" .. string.rep("\143", length - 1)) --\x83
  872.         m.setTextColor(colors[color3])
  873.         m.setBackgroundColor(oldcol)
  874.         m.write("\144")
  875.     end
  876.     m.setCursorPos(pos1 - 1, pos2 + height)
  877.     if thicc then
  878.         m.setBackgroundColor(oldcol)
  879.         m.setTextColor(colors[color3])
  880.         m.write(string.rep("\x8f", length + 1)) --\131
  881.         m.setBackgroundColor(colors[color1])
  882.         m.setTextColor(colors[color3])
  883.     else
  884.         m.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  885.     end
  886.     for i = 0, (height * 2) - 2 do
  887.         if not thicc then
  888.             m.setTextColor(xm)
  889.             m.setBackgroundColor(xb)
  890.         end
  891.         m.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  892.         if thicc then
  893.             m.setBackgroundColor(colors[color3])
  894.         end
  895.         m.setBackgroundColor(colors[color3])
  896.         m.write("\x95")
  897.         m.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  898.         if not thicc then
  899.             m.setTextColor(xb)
  900.             m.setBackgroundColor(xm)
  901.         end
  902.         m.setTextColor(colors[color3])
  903.         m.write("\x95")
  904.     end
  905.     m.setBackgroundColor(oldcol)
  906.     m.setTextColor(oldcol1)
  907. end
  908.  
  909. --*functions usages
  910. --*API(ins, cord1, cord2, length, height)
  911. --*timetouch(timeout)
  912. --*touch()
  913. --*button(lr,ins, cord1, cord2, text)
  914. --*counter(lr, ins, cc, cord1, cord2, cv, max, min, col)
  915. --*fill(pos1, pos2, length, height)
  916. --*switch(lr, ccins, pos1, pos2, col1, col2, col3, text)
  917. --*switchn(lr, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  918. --*bundle(side, color, state)
  919. --*signal(side, ins, col)
  920. --*sliderVer/Hor(lr, ins, cc, pos1, pos2, length, color1, textCol)
  921. --*local function menu(lr, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)  (returns menuout)
  922. --*bar(pos1, pos2, length, height, ins, max, color1, color2, color3, printval, hor, text, format, rect, thicc)
  923. --*timeswitch(lr, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  924. --*render(text,x,y,textcol,backCol)
  925. --*menudata()
  926. --*frame(pos1, pos2, length, height, color3, color1, thicc)
  927. --*db allows you to get stored data from all functions that use stored data!
  928. --*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
  929.  
  930. --base API this API is made for detecting clicks in an area
  931. function terminal.API(ins, cord1, cord2, length, height)
  932.     expect(1, ins, "table")
  933.     expect(2, cord1, "number")
  934.     expect(3, cord2, "number")
  935.     expect(4, length, "number")
  936.     expect(5, height, "number")
  937.     if ins == true then
  938.         ins = {os.pullEvent("mouse_click")}
  939.     end
  940.     if ins[3] >= cord1 and ins[3] <= cord1 + length - 1 then
  941.         if ins[4] >= cord2 and ins[4] <= cord2 + height - 1 then
  942.             return true
  943.         else
  944.             return false
  945.         end
  946.     end
  947. end
  948.  
  949. function terminal.touch()
  950.     local dats = {os.pullEvent("mouse_click")}
  951.     return dats
  952. end
  953.  
  954. function terminal.timetouch(timeout)
  955.     expect(1, timeout, "number")
  956.     local timer = os.startTimer(timeout)
  957.     while true do
  958.         local event = {os.pullEvent()}
  959.         if (event[1] == "timer") and (event[2] == timer) then
  960.             return {"timeout", "tout", 1000, 1000}
  961.         elseif (event[1] == "mouse_click") then
  962.             return {event[1], event[2], event[3], event[4]}
  963.         end
  964.     end
  965. end
  966.  
  967. -------------------------------------------------------------------------------------------------
  968.  
  969. function terminal.button(lr, ins, cord1, cord2, text)
  970.     expect(1, lr, "number")
  971.     expect(2, ins, "table")
  972.     expect(3, cord1, "number")
  973.     expect(4, cord2, "number")
  974.     expect(5, text, "string")
  975.     if ins[2] == lr or ins[2] == "tout" then
  976.         if ins ~= nil then
  977.             local x = terminal.API(ins, cord1, cord2, string.len(text), 1)
  978.             term.setCursorPos(cord1, cord2)
  979.             term.write(text)
  980.             return x
  981.         end
  982.     end
  983. end
  984.  
  985. function terminal.counter(lr, ins, cc, cord1, cord2, cv, max, min, col)
  986.     if lr == "db" then
  987.         if data == nil then
  988.             return nil
  989.         else
  990.             return data[ins]
  991.         end
  992.     end
  993.     if lr == "setdb" then
  994.         if data == nil then
  995.             return "no data to edit"
  996.         else
  997.             data[ins] = cc
  998.             return ("value changed too " .. type(cc))
  999.         end
  1000.     end
  1001.     expect(1, lr, "number")
  1002.     expect(2, ins, "table")
  1003.     expect(3, cc, "number")
  1004.     expect(4, cord1, "number")
  1005.     expect(5, cord2, "number")
  1006.     expect(6, cv, "number")
  1007.     expect(7, max, "number")
  1008.     expect(8, min, "number")
  1009.     expect(9, col, "string")
  1010.     if ins[2] == lr or ins[2] == "tout" then
  1011.         if ins ~= nil then
  1012.             if data == nil then
  1013.                 data = {}
  1014.                 for is = 0, 1000 do
  1015.                     data[is] = 0
  1016.                 end
  1017.             end
  1018.             term.setCursorPos(cord1, cord2)
  1019.             term.write("\24" .. " " .. data[cc])
  1020.             term.setCursorPos(cord1, cord2 + 1)
  1021.             term.write("\25")
  1022.             if terminal.API(ins, cord1, cord2, 1, 1) == true then
  1023.                 if data[cc] < max then
  1024.                     data[cc] = data[cc] + cv
  1025.                     term.setCursorPos(cord1, cord2)
  1026.                     term.setTextColor(colors.green)
  1027.                     term.write("\24" .. " " .. data[cc] .. " ")
  1028.                     term.setCursorPos(cord1, cord2 + 1)
  1029.                     term.setTextColor(colors.red)
  1030.                     term.write("\25")
  1031.                     term.setTextColor(colors[col])
  1032.                     return data[cc]
  1033.                 end
  1034.             end
  1035.         end
  1036.         if terminal.API(ins, cord1, cord2 + 1, 1, 1) == true then
  1037.             if data[cc] > min then
  1038.                 data[cc] = data[cc] - cv
  1039.                 term.setCursorPos(cord1, cord2)
  1040.                 term.setTextColor(colors.green)
  1041.                 term.write("\24" .. " " .. data[cc] .. " ")
  1042.                 term.setCursorPos(cord1, cord2 + 1)
  1043.                 term.setTextColor(colors.red)
  1044.                 term.write("\25")
  1045.                 term.setTextColor(colors[col])
  1046.                 return data[cc]
  1047.             end
  1048.         end
  1049.     end
  1050. end
  1051.  
  1052. function terminal.fill(pos1, pos2, length, height)
  1053.     expect(1, pos1, "number")
  1054.     expect(2, pos2, "number")
  1055.     expect(3, length, "number")
  1056.     expect(4, height, "number")
  1057.     for x = 0, height - 1 do
  1058.         term.setCursorPos(pos1, pos2 + x)
  1059.         term.write(string.rep(" ", length))
  1060.     end
  1061. end
  1062.  
  1063. function terminal.switch(lr, cc, ins, pos1, pos2, col1, col2, col3, text)
  1064.     if lr == "db" then
  1065.         if data1 == nil then
  1066.             return nil
  1067.         else
  1068.             return data1[cc]
  1069.         end
  1070.     end
  1071.     if lr == "setdb" then
  1072.         if data1 == nil then
  1073.             return "no data to edit"
  1074.         else
  1075.             data1[cc] = ins
  1076.             return ("value changed too " .. type(ins))
  1077.         end
  1078.     end
  1079.     expect(1, lr, "number")
  1080.     expect(2, cc, "number")
  1081.     expect(3, ins, "table")
  1082.     expect(4, pos1, "number")
  1083.     expect(5, pos2, "number")
  1084.     expect(6, col1, "string")
  1085.     expect(7, col2, "string")
  1086.     expect(8, col3, "string")
  1087.     expect(9, text, "string")
  1088.     if ins[2] == lr or ins[2] == "tout" then
  1089.         if ins ~= nil then
  1090.             local re = string.len(text)
  1091.             if data1 == nil then
  1092.                 data1 = {}
  1093.                 for is = 0, 1000 do
  1094.                     data1[is] = false
  1095.                 end
  1096.             end
  1097.             local function ff()
  1098.                 data1[cc] = not data1[cc]
  1099.             end
  1100.             if terminal.API(ins, pos1, pos2, string.len(text), 1) == true then
  1101.                 ff()
  1102.             end
  1103.             local oldcol1 = term.getTextColor()
  1104.             local oldcol2 = term.getBackgroundColor()
  1105.             if data1[cc] == true then
  1106.                 term.setBackgroundColor(colors[col2])
  1107.             else
  1108.                 term.setBackgroundColor(colors[col1])
  1109.             end
  1110.             term.setCursorPos(pos1, pos2)
  1111.             term.setTextColor(colors[col3])
  1112.             term.write(text)
  1113.             term.setTextColor(oldcol1)
  1114.             term.setBackgroundColor(oldcol2)
  1115.             return (data1[cc])
  1116.         end
  1117.     end
  1118. end
  1119.  
  1120. function terminal.switchn(lr, cc, ins, pos1, pos2, col1, col2, col3, text, text2)
  1121.     if lr == "db" then
  1122.         if data2 == nil then
  1123.             return nil
  1124.         else
  1125.             return data2[cc]
  1126.         end
  1127.     end
  1128.     if lr == "setdb" then
  1129.         if data2 == nil then
  1130.             return "no data to edit"
  1131.         else
  1132.             data2[cc] = ins
  1133.             return ("value changed too " .. type(ins))
  1134.         end
  1135.     end
  1136.     expect(1, lr, "number")
  1137.     expect(2, cc, "number")
  1138.     expect(3, ins, "table")
  1139.     expect(4, pos1, "number")
  1140.     expect(5, pos2, "number")
  1141.     expect(6, col1, "string")
  1142.     expect(7, col2, "string")
  1143.     expect(8, col3, "string")
  1144.     expect(9, text, "string")
  1145.     expect(10, text2, "string")
  1146.     if ins[2] == lr or ins[2] == "tout" then
  1147.         if ins ~= nil then
  1148.             local re = string.len(text)
  1149.             if string.len(text) ~= string.len(text2) then
  1150.                 if string.len(text) > string.len(text2) then
  1151.                     re = string.len(text)
  1152.                 else
  1153.                     re = string.len(text2)
  1154.                 end
  1155.             end
  1156.             if data2 == nil then
  1157.                 data2 = {}
  1158.                 for is = 0, 1000 do
  1159.                     data2[is] = false
  1160.                 end
  1161.             end
  1162.             local function ff()
  1163.                 data2[cc] = not data2[cc]
  1164.             end
  1165.             if terminal.API(ins, pos1, pos2, re, 1) == true then
  1166.                 ff()
  1167.             end
  1168.             local oldcol1 = term.getTextColor()
  1169.             local oldcol2 = term.getBackgroundColor()
  1170.             if data2[cc] == true then
  1171.                 term.setCursorPos(pos1, pos2)
  1172.                 if string.len(text) ~= string.len(text2) then
  1173.                     term.write(string.rep(" ", re))
  1174.                 end
  1175.                 term.setBackgroundColor(colors[col2])
  1176.                 term.setCursorPos(pos1, pos2)
  1177.                 term.setTextColor(colors[col3])
  1178.                 term.write(text2)
  1179.             else
  1180.                 term.setCursorPos(pos1, pos2)
  1181.                 if string.len(text) ~= string.len(text2) then
  1182.                     term.write(string.rep(" ", re))
  1183.                 end
  1184.                 term.setBackgroundColor(colors[col1])
  1185.                 term.setCursorPos(pos1, pos2)
  1186.                 term.setTextColor(colors[col3])
  1187.                 term.write(text)
  1188.             end
  1189.             term.setTextColor(oldcol1)
  1190.             term.setBackgroundColor(oldcol2)
  1191.             return (data2[cc])
  1192.         end
  1193.     end
  1194. end
  1195. -- bundle cable APIs for using main API with bundled cables
  1196. function terminal.bundle(side, color, state)
  1197.     expect(1, side, "string")
  1198.     expect(2, color, "number")
  1199.     expect(3, state, "boolean")
  1200.     if (type(side) == "string") and (type(color) == "number") and (type(state) == "boolean") then
  1201.         if state == true then
  1202.             rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side), color))
  1203.         elseif state == false then
  1204.             rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side), color))
  1205.         end
  1206.     else
  1207.         error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")
  1208.     end
  1209. end
  1210.  
  1211. function terminal.signal(side, ins, col, func)
  1212.     expect(1, side, "string")
  1213.     expect(2, ins, "boolean", "string")
  1214.     expect(3, col, "number")
  1215.     expect(4, func, "boolean")
  1216.     if ins == "clear" then
  1217.         rs.setBundledOutput(side, 0)
  1218.     else
  1219.         if func == true then
  1220.             if ins == "on" then
  1221.                 ins = true
  1222.             end
  1223.             if ins == "nil" then
  1224.                 ins = false
  1225.             end
  1226.         end
  1227.         if ins ~= nil then
  1228.             if ins == true then
  1229.                 bundle(side, col, true)
  1230.             elseif ins == false then
  1231.                 bundle(side, col, false)
  1232.             end
  1233.         end
  1234.     end
  1235. end
  1236. -------------------------------------------------------------------------------------------------
  1237.  
  1238. function terminal.sliderHor(lr, ins, cc, pos1, pos2, length, color1, textCol)
  1239.     if lr == "db" then
  1240.         if data3 == nil then
  1241.             return nil
  1242.         else
  1243.             return data3[ins]
  1244.         end
  1245.     end
  1246.     if lr == "setdb" then
  1247.         if data3 == nil then
  1248.             return "no data to edit"
  1249.         else
  1250.             data3[ins] = cc
  1251.             return ("value changed too " .. type(cc))
  1252.         end
  1253.     end
  1254.     expect(1, lr, "number")
  1255.     expect(2, ins, "table")
  1256.     expect(3, cc, "number")
  1257.     expect(4, pos1, "number")
  1258.     expect(5, pos2, "number")
  1259.     expect(6, length, "number")
  1260.     expect(7, color1, "string")
  1261.     expect(8, textCol, "string")
  1262.     if ins[2] == lr or ins[2] == "tout" then
  1263.         if ins ~= nil then
  1264.             local oldcol1 = term.getBackgroundColor()
  1265.             local oldcol2 = term.getTextColor()
  1266.             term.setBackgroundColor(colors[color1])
  1267.             term.setTextColor(colors[textCol])
  1268.             term.setCursorPos(pos1, pos2)
  1269.             for i = 0, length do
  1270.                 term.write("-")
  1271.                 term.setCursorPos(pos1 + i, pos2)
  1272.             end
  1273.             if data3 == nil then
  1274.                 data3 = {}
  1275.                 for is = 0, 1000 do
  1276.                     data3[is] = 0
  1277.                 end
  1278.             end
  1279.             local cp = (ins[3])
  1280.             if (ins[4] == pos2) and (ins[3] >= pos1) and (ins[3] <= (pos1 + length) - 1) then
  1281.                 term.setCursorPos(cp, pos2)
  1282.                 data3[cc] = cp
  1283.                 term.write("|")
  1284.             else
  1285.                 term.setCursorPos(data3[cc], pos2)
  1286.                 term.write("|")
  1287.             end
  1288.             term.setBackgroundColor(oldcol1)
  1289.             term.setTextColor(oldcol2)
  1290.             if data3[cc] - pos1 >= 0 then
  1291.                 return (data3[cc] - pos1)
  1292.             elseif data3[cc] - pos1 < 0 then
  1293.                 return 0
  1294.             end
  1295.         end
  1296.     end
  1297. end
  1298.  
  1299. function terminal.sliderVer(lr, ins, cc, pos1, pos2, length, color1, textCol)
  1300.     if lr == "db" then
  1301.         if data10 == nil then
  1302.             return nil
  1303.         else
  1304.             return data10[ins]
  1305.         end
  1306.     end
  1307.     if lr == "setdb" then
  1308.         if data10 == nil then
  1309.             return "no data to edit"
  1310.         else
  1311.             data10[ins] = cc
  1312.             return ("value changed too " .. type(cc))
  1313.         end
  1314.     end
  1315.     expect(1, lr, "number")
  1316.     expect(2, ins, "table")
  1317.     expect(3, cc, "number")
  1318.     expect(4, pos1, "number")
  1319.     expect(5, pos2, "number")
  1320.     expect(6, length, "number")
  1321.     expect(7, color1, "string")
  1322.     expect(8, textCol, "string")
  1323.     if ins[2] == lr or ins[2] == "tout" then
  1324.         if ins ~= nil then
  1325.             local oldcol1 = term.getBackgroundColor()
  1326.             local oldcol2 = term.getTextColor()
  1327.             term.setBackgroundColor(colors[color1])
  1328.             term.setTextColor(colors[textCol])
  1329.             term.setCursorPos(pos1, pos2)
  1330.             for i = 0, length do
  1331.                 term.write("\124")
  1332.                 term.setCursorPos(pos1, pos2 - i)
  1333.             end
  1334.             if data10 == nil then
  1335.                 data10 = {}
  1336.                 for is = 0, 1000 do
  1337.                     data10[is] = 0
  1338.                 end
  1339.             end
  1340.             local cp = ins[4]
  1341.             if (ins[3] == pos1) and (ins[4] <= pos2) and (ins[4] >= (pos2 - length) + 1) then
  1342.                 term.setCursorPos(pos1, cp)
  1343.                 data10[cc] = cp
  1344.                 term.write("\xad")
  1345.             else
  1346.                 term.setCursorPos(pos1, data10[cc])
  1347.                 term.write("\xad")
  1348.             end
  1349.             term.setBackgroundColor(oldcol1)
  1350.             term.setTextColor(oldcol2)
  1351.             if data10[cc] - pos1 >= 0 then
  1352.                 return (data10[cc] - pos1)
  1353.             elseif data10[cc] - pos1 < 0 then
  1354.                 return 0
  1355.             end
  1356.         end
  1357.     end
  1358. end
  1359.  
  1360. function terminal.render(text, x, y, textcol, backCol)
  1361.     expect(1, text, "string")
  1362.     expect(2, x, "number")
  1363.     expect(3, y, "number")
  1364.     expect(4, textcol, "string")
  1365.     expect(5, backCol, "string", "number")
  1366.     local oldcol1 = term.getBackgroundColor()
  1367.     local oldcol2 = term.getTextColor()
  1368.     local cur = {term.getCursorPos()}
  1369.     term.setTextColor(colors[textcol])
  1370.     if type(backCol) == "string" then
  1371.         term.setBackgroundColor(colors[backCol])
  1372.     elseif type(backCol) == "number" then
  1373.         term.setBackgroundColor(backCol)
  1374.     end
  1375.     term.setCursorPos(x, y)
  1376.     term.write(text)
  1377.     term.setBackgroundColor(oldcol1)
  1378.     term.setTextColor(oldcol2)
  1379.     term.setCursorPos(cur[1], cur[2])
  1380. end
  1381.  
  1382. function terminal.menu(lr, ins, cc, x, y, textcol, switchcol, text, returns1, more, returns2)
  1383.     expect(1, lr, "number")
  1384.     expect(2, ins, "table")
  1385.     expect(3, cc, "number")
  1386.     expect(4, x, "number")
  1387.     expect(5, y, "number")
  1388.     expect(6, textcol, "string")
  1389.     expect(7, switchcol, "string")
  1390.     expect(8, text, "string")
  1391.     expect(9, returns1, "string", "number", "boolean", "nil")
  1392.     expect(10, more, "boolean")
  1393.     expect(11, returns2, "string", "number", "boolean", "nil")
  1394.     if ins[2] == lr or ins[2] == "tout" then
  1395.         if thisIsUseless == nil then
  1396.             for i = 0, 1000 do
  1397.                 thisIsUseless = {}
  1398.                 thisIsUseless[i] = false
  1399.             end
  1400.         end
  1401.         if not thisIsUseless[cc] then
  1402.             terminal.render(text, x, y, textcol, oldcol2)
  1403.         end
  1404.         if ins ~= nil then
  1405.             local oldcol1 = term.getTextColor()
  1406.             local oldcol2 = term.getBackgroundColor()
  1407.             local l = string.len(text)
  1408.             if ins[1] ~= "timeout" then
  1409.                 if data4 == nil then
  1410.                     data4 = {}
  1411.                     for is = 0, 1000 do
  1412.                         data4[is] = false
  1413.                     end
  1414.                 end
  1415.                 if data5 == nil then
  1416.                     data5 = {}
  1417.                     for is = 0, 1000 do
  1418.                         data5[is] = false
  1419.                     end
  1420.                 end
  1421.                 if data6 == nil then
  1422.                     data6 = {}
  1423.                     for is = 0, 1000 do
  1424.                         data6[is] = false
  1425.                     end
  1426.                 end
  1427.                 if terminal.API(ins, x, y, l, 1) == true then
  1428.                     data4[cc] = text
  1429.                     data5[cc] = x
  1430.                     data6[cc] = y
  1431.                     local function menus()
  1432.                         for i = 1, 500 do
  1433.                             if data4[i] ~= false then
  1434.                                 term.setBackgroundColor(oldcol2)
  1435.                                 term.setCursorPos(data5[i], data6[i])
  1436.                                 term.setTextColor(colors[textcol])
  1437.                                 term.write(data4[i])
  1438.                             end
  1439.                         end
  1440.                         local i = 0
  1441.                     end
  1442.                     menus()
  1443.                     term.setCursorPos(data5[cc], data6[cc])
  1444.                     term.setBackgroundColor(colors[switchcol])
  1445.                     term.setTextColor(colors[textcol])
  1446.                     term.write(text)
  1447.                     term.setTextColor(oldcol1)
  1448.                     term.setBackgroundColor(oldcol2)
  1449.                     menuout = text
  1450.                     if returns1 == nil then
  1451.                         return menuout
  1452.                     else
  1453.                         if (more == nil) or (more == false) then
  1454.                             menuout = returns1
  1455.                             return menuout
  1456.                         else
  1457.                             menuout = {
  1458.                                 returns1,
  1459.                                 returns2
  1460.                             }
  1461.                             if menuout == nil then
  1462.                                 return 0
  1463.                             end
  1464.                             return menuout
  1465.                         end
  1466.                     end
  1467.                 end
  1468.             end
  1469.         end
  1470.     end
  1471.     thisIsUseless[cc] = true
  1472.     if more == true then
  1473.         if menuout == nil then
  1474.             menuout = {returns1, "nil"}
  1475.         end
  1476.     end
  1477. end
  1478.  
  1479. function terminal.menudata()
  1480.     if menuout ~= nil then
  1481.         return menuout
  1482.     else
  1483.         return "no output"
  1484.     end
  1485. end
  1486.  
  1487. function terminal.timeswitch(lr, ins, cc, pos1, pos2, change, start, col1, col2, col3, repeats)
  1488.     if lr == "db" then
  1489.         if data7 == nil then
  1490.             return nil
  1491.         else
  1492.             return data7[ins]
  1493.         end
  1494.     end
  1495.     if lr == "setdb" then
  1496.         if data7 == nil then
  1497.             return "no data to edit"
  1498.         else
  1499.             data7[ins] = cc
  1500.             return ("value changed too " .. type(cc))
  1501.         end
  1502.     end
  1503.     expect(1, lr, "number")
  1504.     expect(2, ins, "table")
  1505.     expect(3, cc, "number")
  1506.     expect(4, pos1, "number")
  1507.     expect(5, pos2, "number")
  1508.     expect(6, change, "number")
  1509.     expect(7, start, "number")
  1510.     expect(8, col1, "string")
  1511.     expect(9, col2, "string")
  1512.     expect(10, col3, "string")
  1513.     expect(11, repeats, "boolean")
  1514.     if ins[2] == lr or ins[2] == "tout" then
  1515.         if ins ~= nil then
  1516.             local oldcol1 = term.getTextColor()
  1517.             local oldcol2 = term.getBackgroundColor()
  1518.             term.setBackgroundColor(colors[col2])
  1519.             term.setTextColor(colors[col1])
  1520.             if data7 == nil then
  1521.                 data7 = {}
  1522.                 for is = 0, 1000 do
  1523.                     data7[is] = false
  1524.                 end
  1525.             end
  1526.             if data8 == nil then
  1527.                 data8 = {}
  1528.                 for is = 0, 1000 do
  1529.                     data8[is] = false
  1530.                 end
  1531.             end
  1532.             if data8[cc] == false then
  1533.                 data8[cc] = start
  1534.                 term.setCursorPos(pos1 + 6, pos2)
  1535.                 term.write(data8[cc])
  1536.             end
  1537.             term.setCursorPos(pos1, pos2)
  1538.             term.write("start")
  1539.             if terminal.API(ins, pos1, pos2, 4, 1) == true then
  1540.                 data7[cc] = true
  1541.             end
  1542.             if data7[cc] == true then
  1543.                 if data8[cc] > 0 then
  1544.                     repeat
  1545.                         timeOut = data8[cc]
  1546.                         term.setBackgroundColor(colors[col3])
  1547.                         data8[cc] = data8[cc] - change
  1548.                         term.setCursorPos(pos1 + 6, pos2)
  1549.                         sleep(1)
  1550.                         term.write(data8[cc])
  1551.                     until data8[cc] == 0
  1552.                     return "ended"
  1553.                 end
  1554.             end
  1555.             if repeats == true then
  1556.                 data8[cc] = start
  1557.             end
  1558.             term.setBackgroundColor(colors[col2])
  1559.             term.setCursorPos(pos1 + 6, pos2)
  1560.             term.write(data8[cc])
  1561.             term.setTextColor(oldcol1)
  1562.             term.setBackgroundColor(oldcol2)
  1563.         end
  1564.     end
  1565. end
  1566.  
  1567. function terminal.bar(
  1568.     pos1,
  1569.     pos2,
  1570.     length,
  1571.     height,
  1572.     ins,
  1573.     max,
  1574.     color1,
  1575.     color2,
  1576.     color3,
  1577.     printval,
  1578.     hor,
  1579.     text,
  1580.     format,
  1581.     rect,
  1582.     thicc)
  1583.     expect(1, pos1, "number")
  1584.     expect(2, pos2, "number")
  1585.     expect(3, length, "number")
  1586.     expect(4, height, "number")
  1587.     expect(5, ins, "number")
  1588.     expect(6, max, "number")
  1589.     expect(7, color1, "string")
  1590.     expect(8, color2, "string")
  1591.     expect(9, color3, "string")
  1592.     expect(10, printval, "boolean")
  1593.     expect(11, hor, "boolean")
  1594.     expect(12, text, "string")
  1595.     expect(13, format, "boolean")
  1596.     expect(14, rect, "boolean")
  1597.     expect(15, thicc, "boolean")
  1598.     if (ins == nil) or (ins < 0) then
  1599.         ins = 0
  1600.     end
  1601.     if format == nil then
  1602.         local format = false
  1603.     end
  1604.     if ins ~= nil then
  1605.         oldcol = term.getBackgroundColor()
  1606.         oldcol1 = term.getTextColor()
  1607.         term.setTextColor(colors[color3])
  1608.         local function reprint()
  1609.             term.setBackgroundColor(colors[color1])
  1610.             terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1611.             term.setBackgroundColor(oldcol)
  1612.             xm = term.getBackgroundColor()
  1613.             xb = term.getTextColor()
  1614.             term.setTextColor(xm)
  1615.             term.setBackgroundColor(xb)
  1616.             term.setCursorPos(pos1 - 1, pos2 - height)
  1617.             if thicc then
  1618.                 term.setBackgroundColor(colors[color3])
  1619.             end
  1620.             if thicc then
  1621.                 term.write(string.rep("\x83", length + 1)) --\143
  1622.                 term.setTextColor(xb)
  1623.                 term.setBackgroundColor(xm)
  1624.             else
  1625.                 term.write("\159" .. string.rep("\143", length - 1)) --\x83
  1626.                 term.setTextColor(xb)
  1627.                 term.setBackgroundColor(xm)
  1628.                 term.write("\144")
  1629.             end
  1630.             if thicc then
  1631.                 term.setBackgroundColor(colors[color3])
  1632.             end
  1633.             term.setCursorPos(pos1 - 1, pos2 + height)
  1634.             if thicc then
  1635.                 term.write(string.rep("\x8c", length + 1)) --\131
  1636.             else
  1637.                 term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  1638.             end
  1639.             for i = 0, (height * 2) - 2 do
  1640.                 if not thicc then
  1641.                     term.setTextColor(xm)
  1642.                     term.setBackgroundColor(xb)
  1643.                 end
  1644.                 term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  1645.                 if thicc then
  1646.                     term.setBackgroundColor(colors[color3])
  1647.                 end
  1648.                 term.write("\x95")
  1649.                 term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  1650.                 if not thicc then
  1651.                     term.setTextColor(xb)
  1652.                     term.setBackgroundColor(xm)
  1653.                 end
  1654.                 term.write("\x95")
  1655.             end
  1656.         end
  1657.         if rect ~= false then
  1658.             reprint()
  1659.         else
  1660.             terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1661.         end
  1662.         local drawLength = ins / max * length
  1663.         local drawHeights = ins / max * height
  1664.         local drawHeight = math.ceil(drawHeights)
  1665.         local moveval = (drawHeight * 2) - 2
  1666.         local z = pos2 + height
  1667.         term.setBackgroundColor(colors[color2])
  1668.         if (hor == false) or (hor == nil) then
  1669.             terminal.fill(pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  1670.         else
  1671.             terminal.fill(pos1, (z - 1) - moveval, length - 1, moveval + 1)
  1672.         end
  1673.         if printval == true then
  1674.             term.setCursorPos(pos1, pos2)
  1675.             term.setTextColor(colors[color3])
  1676.             if hor == true then
  1677.                 if format then
  1678.                     if ins >= max / 2 then
  1679.                         term.setBackgroundColor(colors[color2])
  1680.                     else
  1681.                         term.setBackgroundColor(colors[color1])
  1682.                     end
  1683.                 else
  1684.                     if ins >= (max / 2) - (max / height) then
  1685.                         term.setBackgroundColor(colors[color2])
  1686.                     else
  1687.                         term.setBackgroundColor(colors[color1])
  1688.                     end
  1689.                 end
  1690.             elseif hor == false then
  1691.                 term.setCursorPos(pos1, pos2)
  1692.                 term.setTextColor(colors[color3])
  1693.                 if hor == true then
  1694.                     if ins >= 1 then
  1695.                         term.setBackgroundColor(colors[color2])
  1696.                     else
  1697.                         term.setBackgroundColor(colors[color1])
  1698.                     end
  1699.                 end
  1700.             end
  1701.             if format then
  1702.                 term.write(ins .. "/" .. max)
  1703.                 term.setCursorPos(pos1, pos2 + 1)
  1704.                 term.write(text)
  1705.             else
  1706.                 term.write(ins .. "/" .. max .. " " .. text)
  1707.             end
  1708.             term.setBackgroundColor(oldcol)
  1709.             term.setTextColor(oldcol1)
  1710.         end
  1711.         term.setTextColor(oldcol1)
  1712.         term.setBackgroundColor(oldcol)
  1713.     end
  1714. end
  1715.  
  1716. function terminal.frame(pos1, pos2, length, height, color3, color1, thicc)
  1717.     expect(1, pos1, "number")
  1718.     expect(2, pos2, "number")
  1719.     expect(3, length, "number")
  1720.     expect(4, height, "number")
  1721.     expect(5, color3, "string")
  1722.     expect(6, color1, "string")
  1723.     expect(7, thicc, "boolean","nil")
  1724.     local oldcol = term.getBackgroundColor()
  1725.     local oldcol1 = term.getTextColor()
  1726.     term.setBackgroundColor(colors[color1])
  1727.     terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  1728.     term.setBackgroundColor(oldcol)
  1729.     xm = term.getBackgroundColor()
  1730.     xb = term.getTextColor()
  1731.     term.setTextColor(xm)
  1732.     term.setBackgroundColor(xb)
  1733.     term.setCursorPos(pos1 - 1, pos2 - height)
  1734.     if thicc then
  1735.         term.setBackgroundColor(colors[color3])
  1736.         term.setTextColor(oldcol)
  1737.         term.write(string.rep("\x83", length + 1)) --\143
  1738.         term.setTextColor(xb)
  1739.         term.setBackgroundColor(xm)
  1740.     else
  1741.         term.setTextColor(oldcol)
  1742.         term.setBackgroundColor(colors[color3])
  1743.         term.write("\159" .. string.rep("\143", length - 1)) --\x83
  1744.         term.setTextColor(colors[color3])
  1745.         term.setBackgroundColor(oldcol)
  1746.         term.write("\144")
  1747.     end
  1748.     term.setCursorPos(pos1 - 1, pos2 + height)
  1749.     if thicc then
  1750.         term.setBackgroundColor(oldcol)
  1751.         term.setTextColor(colors[color3])
  1752.         term.write(string.rep("\x8f", length + 1)) --\131
  1753.         term.setBackgroundColor(colors[color1])
  1754.         term.setTextColor(colors[color3])
  1755.     else
  1756.         term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  1757.     end
  1758.     for i = 0, (height * 2) - 2 do
  1759.         if not thicc then
  1760.             term.setTextColor(xm)
  1761.             term.setBackgroundColor(xb)
  1762.         end
  1763.         term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  1764.         if thicc then
  1765.             term.setBackgroundColor(colors[color3])
  1766.         end
  1767.         term.setBackgroundColor(colors[color3])
  1768.         term.write("\x95")
  1769.         term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  1770.         if not thicc then
  1771.             term.setTextColor(xb)
  1772.             term.setBackgroundColor(xm)
  1773.         end
  1774.         term.setTextColor(colors[color3])
  1775.         term.write("\x95")
  1776.     end
  1777.     term.setBackgroundColor(oldcol)
  1778.     term.setTextColor(oldcol1)
  1779. end
  1780.  
  1781. return {
  1782.     monitor = monitor,
  1783.     terminal = terminal
  1784. }
  1785.  
Add Comment
Please, Sign In to add comment