9551

Untitled

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