9551

new backup

Aug 31st, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 47.37 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, cc, ins, 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. --*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. --*render(monitor,text,x,y,textcol,backCol)
  29. --*menudata()
  30. --*frame(monitor, pos1, pos2, length, height, color3, color1, thicc)
  31. --*db allows you to get stored data from all functions that use stored data!
  32. --*how to use db:  in your function for example switch you do   b.switch("db",<data>) data is the storing position you want to get data of
  33. local e = {}
  34. local t = {}
  35.  
  36. local a = require("cc.expect").expect
  37. function e.fill(N, S, H, R, D)
  38.     a(1, N, "string")
  39.     a(2, S, "number")
  40.     a(3, H, "number")
  41.     a(4, R, "number")
  42.     a(5, D, "number")
  43.     local L = peripheral.wrap(N)
  44.     for U = 0, D - 1 do
  45.         L.setCursorPos(S, H + U)
  46.         L.write(string.rep(" ", R))
  47.     end
  48. end
  49. function e.API(o, i, n, s, h)
  50.     a(1, o, "table")
  51.     a(2, i, "number")
  52.     a(3, n, "number")
  53.     a(4, s, "number")
  54.     a(5, h, "number")
  55.     if o == true then
  56.         o = {os.pullEvent("monitor_touch")}
  57.     end
  58.     if o[3] >= i and o[3] <= i + s - 1 then
  59.         return o[4] >= n and o[4] <= n + h - 1
  60.     end
  61. end
  62. function e.boxAPI(ins,x,y,xp,yp,text)
  63.     a(1,ins,"table")
  64.     a(2,x,"number")
  65.     a(3,y,"number")
  66.     a(4,xp,"number")
  67.     a(5,yp,"number")
  68.     a(6,text,"string")
  69.     local fx = x-xp+1
  70.     local fy = y-yp
  71.     local lenx = #text-2
  72.     local didmo = false
  73.     if xp >= 1 then xp = xp - 1 didmo = true end
  74.     if xp > 0 or didmo then lenx = #text+xp*2 fx=fx-1 end
  75.     local leny = yp*2+1
  76.     return e.API(ins,fx-1,fy,lenx+2,leny),{fx,fy,lenx,leny}
  77. end
  78. function e.boxButton(mon,ins,x,y,bcol,tcol,txt,xp,yp)
  79.     a(1,mon,"string")
  80.     a(2,ins,"table")
  81.     a(3,x,"number")
  82.     a(4,y,"number")
  83.     a(5,bcol,"string")
  84.     a(6,tcol,"string")
  85.     a(7,txt,"string","number","nil")
  86.     a(8,xp,"number","nil")
  87.     a(9,yp,"number","nil")
  88.     if not xp then xp = 0 end
  89.     if not yp then yp = 0 end
  90.     if not txt then txt = "" end
  91.     local txt = tostring(txt)
  92.     if ins[2] == mon then
  93.         if ins ~= nil then
  94.             local m = peripheral.wrap(mon)
  95.             local otc,obc = m.getTextColor(),m.getBackgroundColor()
  96.             m.setBackgroundColor(colors[bcol])
  97.             m.setTextColor(colors[tcol])
  98.             local state, pos = e.boxAPI(ins,x,y,xp or 1,yp or 1,txt)
  99.             e.fill(mon,pos[1]-1,pos[2],pos[3]+2,pos[4])
  100.             local x1,y1,x2,y2 = pos[1],pos[2],pos[3]+pos[1],pos[4]+pos[2]
  101.             m.setCursorPos(
  102.                 math.floor(x1 + (x2 - x1) / 2 - txt:len() / 2 + 0.5),
  103.                 math.floor(y1 + (y2 - y1) / 2)
  104.             )
  105.             m.write(txt)
  106.             m.setBackgroundColor(obc)
  107.             m.setTextColor(otc)
  108.             return state
  109.         end
  110.     end
  111. end
  112. function e.touch()
  113.     local r = {os.pullEvent("monitor_touch")}
  114.     return r
  115. end
  116. function e.timetouch(d, l)
  117.     a(1, d, "number")
  118.     a(2, l, "string")
  119.     local u = os.startTimer(d)
  120.     while true do
  121.         local c = {os.pullEvent()}
  122.         if c[1] == "timer" and c[2] == u then
  123.             return {"timeout", l, 1000, 1000}
  124.         elseif c[1] == "monitor_touch" and c[2] == l then
  125.             return {c[1], c[2], c[3], c[4]}
  126.         end
  127.     end
  128. end
  129. function e.button(f, w, y, p, v)
  130.     a(1, f, "string")
  131.     a(2, w, "table")
  132.     a(3, y, "number")
  133.     a(4, p, "number")
  134.     a(5, v, "string")
  135.     if w[2] == f then
  136.         if w ~= nil then
  137.             local m = peripheral.wrap(f)
  138.             local x = e.API(w, y, p, #v, 1)
  139.             m.setCursorPos(y, p)
  140.             m.write(v)
  141.             return x
  142.         end
  143.     end
  144. end
  145. function e.counter(b, g, k, q, j, z, E, T, A)
  146.     if b == "db" then
  147.         if data == nil then
  148.             return nil
  149.         else
  150.             return data[g]
  151.         end
  152.     end
  153.     if b == "setdb" then
  154.         if data == nil then
  155.             return "no data to edit"
  156.         else
  157.             data[g] = k
  158.             return "value changed too " .. type(k)
  159.         end
  160.     end
  161.     a(1, b, "string")
  162.     a(2, g, "table")
  163.     a(3, k, "number")
  164.     a(4, q, "number")
  165.     a(5, j, "number")
  166.     a(6, z, "number")
  167.     a(7, E, "number")
  168.     a(8, T, "number")
  169.     a(9, A, "string")
  170.     if g[2] == b then
  171.         if g ~= nil then
  172.             local O = peripheral.wrap(b)
  173.             if data == nil then
  174.                 data = {}
  175.                 for I = 0, 1000 do
  176.                     data[I] = 0
  177.                 end
  178.             end
  179.             O.setCursorPos(q, j)
  180.             O.write("\24" .. " " .. data[k])
  181.             O.setCursorPos(q, j + 1)
  182.             O.write("\25")
  183.             if e.API(g, q, j, 1, 1) == true then
  184.                 if data[k] < E then
  185.                     data[k] = data[k] + z
  186.                     O.setCursorPos(q, j)
  187.                     O.setTextColor(colors.green)
  188.                     O.write("\24" .. " " .. data[k] .. " ")
  189.                     O.setCursorPos(q, j + 1)
  190.                     O.setTextColor(colors.red)
  191.                     O.write("\25")
  192.                     O.setTextColor(colors[A])
  193.                     return data[k]
  194.                 end
  195.             end
  196.         end
  197.         if e.API(g, q, j + 1, 1, 1) == true then
  198.             if data[k] > T then
  199.                 data[k] = data[k] - z
  200.                 m.setCursorPos(q, j)
  201.                 m.setTextColor(colors.green)
  202.                 m.write("\24" .. " " .. data[k] .. " ")
  203.                 m.setCursorPos(q, j + 1)
  204.                 m.setTextColor(colors.red)
  205.                 m.write("\25")
  206.                 m.setTextColor(colors[A])
  207.                 return data[k]
  208.             end
  209.         end
  210.     end
  211. end
  212. function e.switch(C, M, F, W, Y, P, V, B, G,xp,yp)
  213.     if C == "db" then
  214.         if data1 == nil then
  215.             return nil
  216.         else
  217.             return data1[M]
  218.         end
  219.     end
  220.     if C == "setdb" then
  221.         if data1 == nil then
  222.             return "no data to edit"
  223.         else
  224.             data1[M] = F
  225.             return "value changed too " .. type(F)
  226.         end
  227.     end
  228.     a(1, C, "string")
  229.     a(2, M, "number")
  230.     a(3, F, "table")
  231.     a(4, W, "number")
  232.     a(5, Y, "number")
  233.     a(6, P, "string")
  234.     a(7, V, "string")
  235.     a(8, B, "string")
  236.     a(9, G, "string")
  237.     a(10, xp, "number","nil")
  238.     a(11, yp, "number","nil")
  239.     if F[2] == C then
  240.         if F ~= nil then
  241.             local K = #G
  242.             local Q = peripheral.wrap(C)
  243.             if data1 == nil then
  244.                 data1 = {}
  245.                 for J = 0, 1000 do
  246.                     data1[J] = false
  247.                 end
  248.             end
  249.             local function X()
  250.                 data1[M] = not data1[M]
  251.             end
  252.             local col
  253.             if not data1[M] then
  254.                 col = P
  255.             else
  256.                 col = V
  257.             end
  258.             if e.boxButton(C,F,W,Y,col,B,G,xp,yp) then
  259.                 X()
  260.             end
  261.             return data1[M]
  262.         end
  263.     end
  264. end
  265. function e.switchn(tt, at, ot, it, nt, st, ht, rt, dt, lt, xp, yp)
  266.     if tt == "db" then
  267.         if data2 == nil then
  268.             return nil
  269.         else
  270.             return data2[at]
  271.         end
  272.     end
  273.     if tt == "setdb" then
  274.         if data2 == nil then
  275.             return "no data to edit"
  276.         else
  277.             data2[at] = ot
  278.             return "value changed too " .. type(ot)
  279.         end
  280.     end
  281.     a(1, tt, "string")
  282.     a(2, at, "number")
  283.     a(3, ot, "table")
  284.     a(4, it, "number")
  285.     a(5, nt, "number")
  286.     a(6, st, "string")
  287.     a(7, ht, "string")
  288.     a(8, rt, "string")
  289.     a(9, dt, "string")
  290.     a(10, lt, "string")
  291.     a(11, xp, "number","nil")
  292.     a(12, yp, "number","nil")
  293.     if ot[2] == tt then
  294.         if ot ~= nil then
  295.             local ct = peripheral.wrap(tt)
  296.             if data2 == nil then
  297.                 data2 = {}
  298.                 for mt = 0, 1000 do
  299.                     data2[mt] = false
  300.                 end
  301.             end
  302.             local function ft()
  303.                 data2[at] = not data2[at]
  304.             end
  305.             local col
  306.             local txt
  307.             if not data2[at] then
  308.                 col = st
  309.                 txt = dt
  310.             else
  311.                 col = ht
  312.                 txt = lt
  313.             end
  314.             if e.boxButton(tt,ot,it,nt,col,rt,txt,xp,yp) then
  315.                 ft()
  316.             end
  317.             return data2[at]
  318.         end
  319.     end
  320. end
  321. function e.bundle(pt, vt, bt)
  322.     a(1, pt, "string")
  323.     a(2, vt, "number")
  324.     a(3, bt, "boolean")
  325.     if bt == true then
  326.         rs.setBundledOutput(pt, colors.combine(rs.getBundledOutput(pt), vt))
  327.     elseif bt == false then
  328.         rs.setBundledOutput(pt, colors.subtract(rs.getBundledOutput(pt), vt))
  329.     end
  330. end
  331. function e.signal(gt, kt, qt, jt)
  332.     a(1, gt, "string")
  333.     a(2, kt, "boolean", "string")
  334.     a(3, qt, "number")
  335.     a(4, jt, "boolean")
  336.     if kt == "clear" then
  337.         rs.setBundledOutput(gt, 0)
  338.     else
  339.         if jt == true then
  340.             if kt == "on" then
  341.                 kt = true
  342.             end
  343.             if kt == "nil" then
  344.                 kt = false
  345.             end
  346.         end
  347.         if kt ~= nil then
  348.             if kt == true then
  349.                 bundle(gt, qt, true)
  350.             elseif kt == false then
  351.                 bundle(gt, qt, false)
  352.             end
  353.         end
  354.     end
  355. end
  356. function e.sliderHor(xt, zt, Et, Tt, At, Ot, It, Nt)
  357.     if xt == "db" then
  358.         if data3 == nil then
  359.             return nil
  360.         else
  361.             return data3[zt]
  362.         end
  363.     end
  364.     if xt == "setdb" then
  365.         if data3 == nil then
  366.             return "no data to edit"
  367.         else
  368.             data3[zt] = Et
  369.             return "value changed too " .. type(Et)
  370.         end
  371.     end
  372.     a(1, xt, "string")
  373.     a(2, zt, "table")
  374.     a(3, Et, "number")
  375.     a(4, Tt, "number")
  376.     a(5, At, "number")
  377.     a(6, Ot, "number")
  378.     a(7, It, "string")
  379.     a(8, Nt, "string")
  380.     if zt[2] == xt then
  381.         if zt ~= nil then
  382.             m = peripheral.wrap(xt)
  383.             local St = m.getBackgroundColor()
  384.             local Ht = m.getTextColor()
  385.             m.setBackgroundColor(colors[It])
  386.             m.setTextColor(colors[Nt])
  387.             m.setCursorPos(Tt, At)
  388.             for Rt = 0, Ot do
  389.                 m.write("-")
  390.                 m.setCursorPos(Tt + Rt, At)
  391.             end
  392.             if data3 == nil then
  393.                 data3 = {}
  394.                 for Dt = 0, 1000 do
  395.                     data3[Dt] = 0
  396.                 end
  397.             end
  398.             local Lt = zt[3]
  399.             if zt[4] == At and zt[3] >= Tt and zt[3] <= Tt + Ot - 1 then
  400.                 m.setCursorPos(Lt, At)
  401.                 data3[Et] = Lt
  402.                 m.write("|")
  403.             else
  404.                 m.setCursorPos(data3[Et], At)
  405.                 m.write("|")
  406.             end
  407.             m.setBackgroundColor(St)
  408.             m.setTextColor(Ht)
  409.             if data3[Et] - Tt >= 0 then
  410.                 return data3[Et] - Tt
  411.             elseif data3[Et] - Tt < 0 then
  412.                 return 0
  413.             end
  414.         end
  415.     end
  416. end
  417. function e.sliderVer(Ut, Ct, Mt, Ft, Wt, Yt, Pt, Vt)
  418.     if Ut == "db" then
  419.         if data10 == nil then
  420.             return nil
  421.         else
  422.             return data10[Ct]
  423.         end
  424.     end
  425.     if Ut == "setdb" then
  426.         if data10 == nil then
  427.             return "no data to edit"
  428.         else
  429.             data10[Ct] = Mt
  430.             return "value changed too " .. type(Mt)
  431.         end
  432.     end
  433.     a(1, Ut, "string")
  434.     a(2, Ct, "table")
  435.     a(3, Mt, "number")
  436.     a(4, Ft, "number")
  437.     a(5, Wt, "number")
  438.     a(6, Yt, "number")
  439.     a(7, Pt, "string")
  440.     a(8, Vt, "string")
  441.     if Ct[2] == Ut then
  442.         if Ct ~= nil then
  443.             m = peripheral.wrap(Ut)
  444.             local Bt = m.getBackgroundColor()
  445.             local Gt = m.getTextColor()
  446.             m.setBackgroundColor(colors[Pt])
  447.             m.setTextColor(colors[Vt])
  448.             m.setCursorPos(Ft, Wt)
  449.             for Kt = 0, Yt do
  450.                 m.write("\124")
  451.                 m.setCursorPos(Ft, Wt - Kt)
  452.             end
  453.             if data10 == nil then
  454.                 data10 = {}
  455.                 for Qt = 0, 1000 do
  456.                     data10[Qt] = 0
  457.                 end
  458.             end
  459.             local Jt = Ct[4]
  460.             if Ct[3] == Ft and Ct[4] <= Wt and Ct[4] >= Wt - Yt + 1 then
  461.                 m.setCursorPos(Ft, Jt)
  462.                 data10[Mt] = Jt
  463.                 m.write("\xad")
  464.             else
  465.                 m.setCursorPos(Ft, data10[Mt])
  466.                 m.write("\xad")
  467.             end
  468.             m.setBackgroundColor(Bt)
  469.             m.setTextColor(Gt)
  470.             if data10[Mt] - Ft >= 0 then
  471.                 return data10[Mt] - Ft
  472.             elseif data10[Mt] - Ft < 0 then
  473.                 return 0
  474.             end
  475.         end
  476.     end
  477. end
  478. function e.render(Xt, Zt, ea, ta, aa, oa)
  479.     a(1, Xt, "string")
  480.     a(2, Zt, "string")
  481.     a(3, ea, "number")
  482.     a(4, ta, "number")
  483.     a(5, aa, "string")
  484.     a(6, oa, "string", "number")
  485.     local ia = peripheral.wrap(Xt)
  486.     local na = ia.getBackgroundColor()
  487.     local sa = ia.getTextColor()
  488.     local ha = {ia.getCursorPos()}
  489.     ia.setTextColor(colors[aa])
  490.     if type(oa) == "string" then
  491.         ia.setBackgroundColor(colors[oa])
  492.     elseif type(oa) == "number" then
  493.         ia.setBackgroundColor(oa)
  494.     end
  495.     ia.setCursorPos(ea, ta)
  496.     ia.write(Zt)
  497.     ia.setBackgroundColor(na)
  498.     ia.setTextColor(sa)
  499.     ia.setCursorPos(ha[1], ha[2])
  500. end
  501. function e.menu(ra, da, la, ua, ca, ma, fa, wa, ya, pa, va)
  502.     a(1, ra, "string")
  503.     a(2, da, "table")
  504.     a(3, la, "number")
  505.     a(4, ua, "number")
  506.     a(5, ca, "number")
  507.     a(6, ma, "string")
  508.     a(7, fa, "string")
  509.     a(8, wa, "string")
  510.     a(9, ya, "string", "number", "boolean", "nil")
  511.     a(10, pa, "boolean")
  512.     a(11, va, "string", "number", "boolean", "nil")
  513.     if da[2] == ra then
  514.         if thisIsUseless == nil then
  515.             for ba = 0, 1000 do
  516.                 thisIsUseless = {}
  517.                 thisIsUseless[ba] = false
  518.             end
  519.         end
  520.         if not thisIsUseless[la] then
  521.             if textcol2 ~= nil then
  522.                 e.render(ra, wa, ua, ca, ma, oldcol2)
  523.             end
  524.         end
  525.         if da ~= nil then
  526.             local ga = peripheral.wrap(ra)
  527.             local ka = ga.getTextColor()
  528.             local qa = ga.getBackgroundColor()
  529.             local ja = #wa
  530.             if da[1] ~= "timeout" then
  531.                 if data4 == nil then
  532.                     data4 = {}
  533.                     for xa = 0, 1000 do
  534.                         data4[xa] = false
  535.                     end
  536.                 end
  537.                 if data5 == nil then
  538.                     data5 = {}
  539.                     for za = 0, 1000 do
  540.                         data5[za] = false
  541.                     end
  542.                 end
  543.                 if data6 == nil then
  544.                     data6 = {}
  545.                     for Ea = 0, 1000 do
  546.                         data6[Ea] = false
  547.                     end
  548.                 end
  549.                 if e.API(da, ua, ca, ja, 1) == true then
  550.                     data4[la] = wa
  551.                     data5[la] = ua
  552.                     data6[la] = ca
  553.                     local function Ta()
  554.                         for Aa = 1, 500 do
  555.                             if data4[Aa] ~= false then
  556.                                 ga.setBackgroundColor(qa)
  557.                                 ga.setCursorPos(data5[Aa], data6[Aa])
  558.                                 ga.setTextColor(colors[ma])
  559.                                 ga.write(data4[Aa])
  560.                             end
  561.                         end
  562.                     end
  563.                     Ta()
  564.                     ga.setCursorPos(data5[la], data6[la])
  565.                     ga.setBackgroundColor(colors[fa])
  566.                     ga.setTextColor(colors[ma])
  567.                     ga.write(wa)
  568.                     ga.setTextColor(ka)
  569.                     ga.setBackgroundColor(qa)
  570.                     menuout = wa
  571.                     if ya == nil then
  572.                         return menuout
  573.                     else
  574.                         if pa == nil or pa == false then
  575.                             menuout = ya
  576.                             return menuout
  577.                         else
  578.                             menuout = {ya, va}
  579.                             if menuout == nil then
  580.                                 return 0
  581.                             end
  582.                             return menuout
  583.                         end
  584.                     end
  585.                 end
  586.             end
  587.         end
  588.     end
  589.     thisIsUseless[la] = true
  590.     if pa == true then
  591.         if menuout == nil then
  592.             menuout = {ya, "nil"}
  593.         end
  594.     end
  595. end
  596. function e.menudata()
  597.     if menuout ~= nil then
  598.         return menuout
  599.     else
  600.         return "no output"
  601.     end
  602. end
  603. function e.bar(Ba, Ga, Ka, Qa, Ja, Xa, Za, eo, to, ao, oo, io, no, so, ho, ro)
  604.     a(1, Ba, "string")
  605.     a(2, Ga, "number")
  606.     a(3, Ka, "number")
  607.     a(4, Qa, "number")
  608.     a(5, Ja, "number")
  609.     a(6, Xa, "number")
  610.     a(7, Za, "number")
  611.     a(8, eo, "string")
  612.     a(9, to, "string")
  613.     a(10, ao, "string")
  614.     a(11, oo, "boolean")
  615.     a(12, io, "boolean")
  616.     a(13, no, "string")
  617.     a(14, so, "boolean")
  618.     a(15, ho, "boolean")
  619.     a(16, ro, "boolean")
  620.     if Xa == nil or Xa < 0 then
  621.         Xa = 0
  622.     end
  623.     if so == nil then
  624.     end
  625.     if Xa ~= nil then
  626.         local lo = peripheral.wrap(Ba)
  627.         oldcol = lo.getBackgroundColor()
  628.         oldcol1 = lo.getTextColor()
  629.         lo.setTextColor(colors[ao])
  630.         local function uo()
  631.             lo.setBackgroundColor(colors[eo])
  632.             e.fill(Ba, Ga - 1, Ka - Ja, Qa, Ja * 2)
  633.             lo.setBackgroundColor(oldcol)
  634.             xm = lo.getBackgroundColor()
  635.             xb = lo.getTextColor()
  636.             lo.setTextColor(xm)
  637.             lo.setBackgroundColor(xb)
  638.             lo.setCursorPos(Ga - 1, Ka - Ja)
  639.             if ro then
  640.                 lo.setBackgroundColor(colors[ao])
  641.             end
  642.             if ro then
  643.                 lo.write(string.rep("\x83", Qa + 1))
  644.                 lo.setTextColor(xb)
  645.                 lo.setBackgroundColor(xm)
  646.             else
  647.                 lo.write("\159" .. string.rep("\143", Qa - 1))
  648.                 lo.setTextColor(xb)
  649.                 lo.setBackgroundColor(xm)
  650.                 lo.write("\144")
  651.             end
  652.             if ro then
  653.                 lo.setBackgroundColor(colors[ao])
  654.             end
  655.             lo.setCursorPos(Ga - 1, Ka + Ja)
  656.             if ro then
  657.                 lo.write(string.rep("\x8c", Qa + 1))
  658.             else
  659.                 lo.write("\130" .. string.rep("\131", Qa - 1) .. "\129")
  660.             end
  661.             for co = 0, Ja * 2 - 2 do
  662.                 if not ro then
  663.                     lo.setTextColor(xm)
  664.                     lo.setBackgroundColor(xb)
  665.                 end
  666.                 lo.setCursorPos(Ga - 1, Ka + co - Ja + 1)
  667.                 if ro then
  668.                     lo.setBackgroundColor(colors[ao])
  669.                 end
  670.                 lo.write("\x95")
  671.                 lo.setCursorPos(Ga - 2 + (Qa + 1), Ka + co - Ja + 1)
  672.                 if not ro then
  673.                     lo.setTextColor(xb)
  674.                     lo.setBackgroundColor(xm)
  675.                 end
  676.                 lo.write("\x95")
  677.             end
  678.         end
  679.         if ho ~= false then
  680.             uo()
  681.         else
  682.             e.fill(Ba, Ga - 1, Ka - Ja, Qa, Ja * 2)
  683.         end
  684.         local mo = Xa / Za * Qa
  685.         local fo = Xa / Za * Ja
  686.         local wo = math.ceil(fo)
  687.         local yo = wo * 2 - 2
  688.         local po = Ka + Ja
  689.         lo.setBackgroundColor(colors[to])
  690.         if io == false or io == nil then
  691.             e.fill(Ba, Ga, Ka - Ja + 1, mo - 1, Ja * 2 - 1)
  692.         else
  693.             e.fill(Ba, Ga, po - 1 - yo, Qa - 1, yo + 1)
  694.         end
  695.         if oo == true then
  696.             lo.setCursorPos(Ga, Ka)
  697.             lo.setTextColor(colors[ao])
  698.             if io == true then
  699.                 if so then
  700.                     if Xa >= Za / 2 then
  701.                         lo.setBackgroundColor(colors[to])
  702.                     else
  703.                         lo.setBackgroundColor(colors[eo])
  704.                     end
  705.                 else
  706.                     if Xa >= Za / 2 - Za / Ja then
  707.                         lo.setBackgroundColor(colors[to])
  708.                     else
  709.                         lo.setBackgroundColor(colors[eo])
  710.                     end
  711.                 end
  712.             elseif io == false then
  713.                 lo.setCursorPos(Ga, Ka)
  714.                 lo.setTextColor(colors[ao])
  715.                 if io == true then
  716.                     if Xa >= 1 then
  717.                         lo.setBackgroundColor(colors[to])
  718.                     else
  719.                         lo.setBackgroundColor(colors[eo])
  720.                     end
  721.                 end
  722.             end
  723.             if so then
  724.                 lo.write(Xa .. "/" .. Za)
  725.                 lo.setCursorPos(Ga, Ka + 1)
  726.                 lo.write(no)
  727.             else
  728.                 lo.write(Xa .. "/" .. Za .. " " .. no)
  729.             end
  730.             lo.setBackgroundColor(oldcol)
  731.             lo.setTextColor(oldcol1)
  732.         end
  733.         lo.setTextColor(oldcol1)
  734.         lo.setBackgroundColor(oldcol)
  735.     end
  736. end
  737. function e.frame(vo, bo, go, ko, qo, jo, xo, zo)
  738.     a(1, vo, "string")
  739.     a(2, bo, "number")
  740.     a(3, go, "number")
  741.     a(4, ko, "number")
  742.     a(5, qo, "number")
  743.     a(6, jo, "string")
  744.     a(7, xo, "string")
  745.     a(8, zo, "boolean", "nil")
  746.     local Eo = peripheral.wrap(vo)
  747.     local To = Eo.getBackgroundColor()
  748.     local Ao = Eo.getTextColor()
  749.     Eo.setBackgroundColor(colors[xo])
  750.     e.fill(vo, bo - 1, go - qo, ko, qo * 2)
  751.     Eo.setBackgroundColor(To)
  752.     xm = Eo.getBackgroundColor()
  753.     xb = Eo.getTextColor()
  754.     Eo.setTextColor(xm)
  755.     Eo.setBackgroundColor(xb)
  756.     Eo.setCursorPos(bo - 1, go - qo)
  757.     if zo then
  758.         Eo.setBackgroundColor(colors[jo])
  759.         Eo.setTextColor(To)
  760.         Eo.write(string.rep("\x83", ko + 1))
  761.         Eo.setTextColor(xb)
  762.         Eo.setBackgroundColor(xm)
  763.     else
  764.         Eo.setTextColor(To)
  765.         Eo.setBackgroundColor(colors[jo])
  766.         Eo.write("\159" .. string.rep("\143", ko - 1))
  767.         Eo.setTextColor(colors[jo])
  768.         Eo.setBackgroundColor(To)
  769.         Eo.write("\144")
  770.     end
  771.     Eo.setCursorPos(bo - 1, go + qo)
  772.     if zo then
  773.         Eo.setBackgroundColor(To)
  774.         Eo.setTextColor(colors[jo])
  775.         Eo.write(string.rep("\x8f", ko + 1))
  776.         Eo.setBackgroundColor(colors[xo])
  777.         Eo.setTextColor(colors[jo])
  778.     else
  779.         Eo.write("\130" .. string.rep("\131", ko - 1) .. "\129")
  780.     end
  781.     for Oo = 0, qo * 2 - 2 do
  782.         if not zo then
  783.             Eo.setTextColor(xm)
  784.             Eo.setBackgroundColor(xb)
  785.         end
  786.         Eo.setCursorPos(bo - 1, go + Oo - qo + 1)
  787.         if zo then
  788.             Eo.setBackgroundColor(colors[jo])
  789.         end
  790.         Eo.setBackgroundColor(colors[jo])
  791.         Eo.write("\x95")
  792.         Eo.setCursorPos(bo - 2 + (ko + 1), go + Oo - qo + 1)
  793.         if not zo then
  794.             Eo.setTextColor(xb)
  795.             Eo.setBackgroundColor(xm)
  796.         end
  797.         Eo.setTextColor(colors[jo])
  798.         Eo.write("\x95")
  799.     end
  800.     Eo.setBackgroundColor(To)
  801.     Eo.setTextColor(Ao)
  802. end
  803. function t.fill(ai, oi, ii, ni)
  804.     a(1, ai, "number")
  805.     a(2, oi, "number")
  806.     a(3, ii, "number")
  807.     a(4, ni, "number")
  808.     for si = 0, ni - 1 do
  809.         term.setCursorPos(ai, oi + si)
  810.         term.write(string.rep(" ", ii))
  811.     end
  812. end
  813. function t.API(Io, No, So, Ho, Ro)
  814.     a(1, Io, "table")
  815.     a(2, No, "number")
  816.     a(3, So, "number")
  817.     a(4, Ho, "number")
  818.     a(5, Ro, "number")
  819.     if Io == true then
  820.         Io = {os.pullEvent("mouse_click")}
  821.     end
  822.     if Io[3] >= No and Io[3] <= No + Ho - 1 then
  823.         return Io[4] >= So and Io[4] <= So + Ro - 1
  824.     end
  825. end
  826. function t.boxAPI(ins,x,y,xp,yp,text)
  827.     a(1,ins,"table")
  828.     a(2,x,"number")
  829.     a(3,y,"number")
  830.     a(4,xp,"number")
  831.     a(5,yp,"number")
  832.     a(6,text,"string")
  833.     local fx = x-xp+1
  834.     local fy = y-yp
  835.     local lenx = #text-2
  836.     local didmo = false
  837.     if xp >= 1 then xp = xp - 1 didmo = true end
  838.     if xp > 0 or didmo then lenx = #text+xp*2 fx=fx-1 end
  839.     local leny = yp*2+1
  840.     return t.API(ins,fx-1,fy,lenx+2,leny),{fx,fy,lenx,leny}
  841. end
  842. function t.boxButton(lr,ins,x,y,bcol,tcol,txt,xp,yp)
  843.     a(1,lr,"number")
  844.     a(2,ins,"table")
  845.     a(3,x,"number")
  846.     a(4,y,"number")
  847.     a(5,bcol,"string")
  848.     a(6,tcol,"string")
  849.     a(7,txt,"string","number","nil")
  850.     a(8,xp,"number","nil")
  851.     a(9,yp,"number","nil")
  852.     if not xp then xp = 0 end
  853.     if not yp then yp = 0 end
  854.     if not txt then txt = "" end
  855.     local txt = tostring(txt)
  856.     if ins[2] == lr or ins[2] == "tout" then
  857.         if ins ~= nil then
  858.             local otc,obc = term.getTextColor(),term.getBackgroundColor()
  859.             term.setBackgroundColor(colors[bcol])
  860.             term.setTextColor(colors[tcol])
  861.             local state, pos = t.boxAPI(ins,x,y,xp or 1,yp or 1,txt)
  862.             t.fill(pos[1]-1,pos[2],pos[3]+2,pos[4])
  863.             local x1,y1,x2,y2 = pos[1],pos[2],pos[3]+pos[1],pos[4]+pos[2]
  864.             term.setCursorPos(
  865.                 math.floor(x1 + (x2 - x1) / 2 - txt:len() / 2 + 0.5),
  866.                 math.floor(y1 + (y2 - y1) / 2)
  867.             )
  868.             term.write(txt)
  869.             term.setBackgroundColor(obc)
  870.             term.setTextColor(otc)
  871.             return state
  872.         end
  873.     end
  874. end
  875. function t.touch()
  876.     local Do = {os.pullEvent("mouse_click")}
  877.     return Do
  878. end
  879. function t.timetouch(Lo)
  880.     a(1, Lo, "number")
  881.     local Uo = os.startTimer(Lo)
  882.     while true do
  883.         local Co = {os.pullEvent()}
  884.         if Co[1] == "timer" and Co[2] == Uo then
  885.             return {"timeout", "tout", 1000, 1000}
  886.         elseif Co[1] == "mouse_click" then
  887.             return {Co[1], Co[2], Co[3], Co[4]}
  888.         end
  889.     end
  890. end
  891. function t.button(Mo, Fo, Wo, Yo, Po)
  892.     a(1, Mo, "number")
  893.     a(2, Fo, "table")
  894.     a(3, Wo, "number")
  895.     a(4, Yo, "number")
  896.     a(5, Po, "string")
  897.     if Fo[2] == Mo or Fo[2] == "tout" then
  898.         if Fo ~= nil then
  899.             local x = t.API(Fo, Wo, Yo, #Po, 1)
  900.             term.setCursorPos(Wo, Yo)
  901.             term.write(Po)
  902.             return x
  903.         end
  904.     end
  905. end
  906. function t.counter(Vo, Bo, Go, Ko, Qo, Jo, Xo, Zo, ei)
  907.     if Vo == "db" then
  908.         if data == nil then
  909.             return nil
  910.         else
  911.             return data[Bo]
  912.         end
  913.     end
  914.     if Vo == "setdb" then
  915.         if data == nil then
  916.             return "no data to edit"
  917.         else
  918.             data[Bo] = Go
  919.             return "value changed too " .. type(Go)
  920.         end
  921.     end
  922.     a(1, Vo, "number")
  923.     a(2, Bo, "table")
  924.     a(3, Go, "number")
  925.     a(4, Ko, "number")
  926.     a(5, Qo, "number")
  927.     a(6, Jo, "number")
  928.     a(7, Xo, "number")
  929.     a(8, Zo, "number")
  930.     a(9, ei, "string")
  931.     if Bo[2] == Vo or Bo[2] == "tout" then
  932.         if Bo ~= nil then
  933.             if data == nil then
  934.                 data = {}
  935.                 for ti = 0, 1000 do
  936.                     data[ti] = 0
  937.                 end
  938.             end
  939.             term.setCursorPos(Ko, Qo)
  940.             term.write("\24" .. " " .. data[Go])
  941.             term.setCursorPos(Ko, Qo + 1)
  942.             term.write("\25")
  943.             if t.API(Bo, Ko, Qo, 1, 1) == true then
  944.                 if data[Go] < Xo then
  945.                     data[Go] = data[Go] + Jo
  946.                     term.setCursorPos(Ko, Qo)
  947.                     term.setTextColor(colors.green)
  948.                     term.write("\24" .. " " .. data[Go] .. " ")
  949.                     term.setCursorPos(Ko, Qo + 1)
  950.                     term.setTextColor(colors.red)
  951.                     term.write("\25")
  952.                     term.setTextColor(colors[ei])
  953.                     return data[Go]
  954.                 end
  955.             end
  956.         end
  957.         if t.API(Bo, Ko, Qo + 1, 1, 1) == true then
  958.             if data[Go] > Zo then
  959.                 data[Go] = data[Go] - Jo
  960.                 term.setCursorPos(Ko, Qo)
  961.                 term.setTextColor(colors.green)
  962.                 term.write("\24" .. " " .. data[Go] .. " ")
  963.                 term.setCursorPos(Ko, Qo + 1)
  964.                 term.setTextColor(colors.red)
  965.                 term.write("\25")
  966.                 term.setTextColor(colors[ei])
  967.                 return data[Go]
  968.             end
  969.         end
  970.     end
  971. end
  972. function t.switch(hi, ri, di, li, ui, ci, mi, fi, wi,xp,yp)
  973.     if hi == "db" then
  974.         if data1 == nil then
  975.             return nil
  976.         else
  977.             return data1[ri]
  978.         end
  979.     end
  980.     if hi == "setdb" then
  981.         if data1 == nil then
  982.             return "no data to edit"
  983.         else
  984.             data1[ri] = di
  985.             return "value changed too " .. type(di)
  986.         end
  987.     end
  988.     a(1, hi, "number")
  989.     a(2, ri, "number")
  990.     a(3, di, "table")
  991.     a(4, li, "number")
  992.     a(5, ui, "number")
  993.     a(6, ci, "string")
  994.     a(7, mi, "string")
  995.     a(8, fi, "string")
  996.     a(9, wi, "string")
  997.     a(10, xp, "number","nil")
  998.     a(11, yp, "number","nil")
  999.     if di[2] == hi or di[2] == "tout" then
  1000.         if di ~= nil then
  1001.             if data1 == nil then
  1002.                 data1 = {}
  1003.                 for pi = 0, 1000 do
  1004.                     data1[pi] = false
  1005.                 end
  1006.             end
  1007.             local function vi()
  1008.                 data1[ri] = not data1[ri]
  1009.             end
  1010.             local col
  1011.             if not data1[ri] then
  1012.                 col = ci
  1013.             else
  1014.                 col = mi
  1015.             end
  1016.             if t.boxButton(hi,di,li,ui,col,fi,wi,xp,yp) then
  1017.                 vi()
  1018.             end
  1019.             return data1[ri]
  1020.         end
  1021.     end
  1022. end
  1023. function t.switchn(ki, qi, ji, xi, zi, Ei, Ti, Ai, Oi, Ii, xp,yp)
  1024.     if ki == "db" then
  1025.         if data2 == nil then
  1026.             return nil
  1027.         else
  1028.             return data2[qi]
  1029.         end
  1030.     end
  1031.     if ki == "setdb" then
  1032.         if data2 == nil then
  1033.             return "no data to edit"
  1034.         else
  1035.             data2[qi] = ji
  1036.             return "value changed too " .. type(ji)
  1037.         end
  1038.     end
  1039.     a(1, ki, "number")
  1040.     a(2, qi, "number")
  1041.     a(3, ji, "table")
  1042.     a(4, xi, "number")
  1043.     a(5, zi, "number")
  1044.     a(6, Ei, "string")
  1045.     a(7, Ti, "string")
  1046.     a(8, Ai, "string")
  1047.     a(9, Oi, "string")
  1048.     a(10, Ii, "string")
  1049.     a(11, xp, "number","nil")
  1050.     a(12, yp, "number","nil")
  1051.     if ji[2] == ki or ji[2] == "tout" then
  1052.         if ji ~= nil then
  1053.             if data2 == nil then
  1054.                 data2 = {}
  1055.                 for Si = 0, 1000 do
  1056.                     data2[Si] = false
  1057.                 end
  1058.             end
  1059.             local function Hi()
  1060.                 data2[qi] = not data2[qi]
  1061.             end
  1062.             local col
  1063.             local txt
  1064.             if not data2[qi] then
  1065.                 col = Ei
  1066.                 txt = Oi
  1067.             else
  1068.                 col = Ti
  1069.                 txt = Ii
  1070.             end
  1071.             if t.boxButton(ki,ji,xi,zi,col,Ai,txt,xp,yp) then
  1072.                 Hi()
  1073.             end
  1074.         end
  1075.     end
  1076. end
  1077. function t.bundle(Li, Ui, Ci)
  1078.     a(1, Li, "string")
  1079.     a(2, Ui, "number")
  1080.     a(3, Ci, "boolean")
  1081.     if type(Li) == "string" and type(Ui) == "number" and type(Ci) == "boolean" then
  1082.         if Ci == true then
  1083.             rs.setBundledOutput(Li, colors.combine(rs.getBundledOutput(Li), Ui))
  1084.         elseif Ci == false then
  1085.             rs.setBundledOutput(Li, colors.subtract(rs.getBundledOutput(Li), Ui))
  1086.         end
  1087.     else
  1088.         error("please use like this:\nbundle(side:string,colors.(color),state:boolean)")
  1089.     end
  1090. end
  1091. function t.signal(Mi, Fi, Wi, Yi)
  1092.     a(1, Mi, "string")
  1093.     a(2, Fi, "boolean", "string")
  1094.     a(3, Wi, "number")
  1095.     a(4, Yi, "boolean")
  1096.     if Fi == "clear" then
  1097.         rs.setBundledOutput(Mi, 0)
  1098.     else
  1099.         if Yi == true then
  1100.             if Fi == "on" then
  1101.                 Fi = true
  1102.             end
  1103.             if Fi == "nil" then
  1104.                 Fi = false
  1105.             end
  1106.         end
  1107.         if Fi ~= nil then
  1108.             if Fi == true then
  1109.                 bundle(Mi, Wi, true)
  1110.             elseif Fi == false then
  1111.                 bundle(Mi, Wi, false)
  1112.             end
  1113.         end
  1114.     end
  1115. end
  1116. function t.sliderHor(Pi, Vi, Bi, Gi, Ki, Qi, Ji, Xi)
  1117.     if Pi == "db" then
  1118.         if data3 == nil then
  1119.             return nil
  1120.         else
  1121.             return data3[Vi]
  1122.         end
  1123.     end
  1124.     if Pi == "setdb" then
  1125.         if data3 == nil then
  1126.             return "no data to edit"
  1127.         else
  1128.             data3[Vi] = Bi
  1129.             return "value changed too " .. type(Bi)
  1130.         end
  1131.     end
  1132.     a(1, Pi, "number")
  1133.     a(2, Vi, "table")
  1134.     a(3, Bi, "number")
  1135.     a(4, Gi, "number")
  1136.     a(5, Ki, "number")
  1137.     a(6, Qi, "number")
  1138.     a(7, Ji, "string")
  1139.     a(8, Xi, "string")
  1140.     if Vi[2] == Pi or Vi[2] == "tout" then
  1141.         if Vi ~= nil then
  1142.             local Zi = term.getBackgroundColor()
  1143.             local en = term.getTextColor()
  1144.             term.setBackgroundColor(colors[Ji])
  1145.             term.setTextColor(colors[Xi])
  1146.             term.setCursorPos(Gi, Ki)
  1147.             for tn = 0, Qi do
  1148.                 term.write("-")
  1149.                 term.setCursorPos(Gi + tn, Ki)
  1150.             end
  1151.             if data3 == nil then
  1152.                 data3 = {}
  1153.                 for an = 0, 1000 do
  1154.                     data3[an] = 0
  1155.                 end
  1156.             end
  1157.             local on = Vi[3]
  1158.             if Vi[4] == Ki and Vi[3] >= Gi and Vi[3] <= Gi + Qi - 1 then
  1159.                 term.setCursorPos(on, Ki)
  1160.                 data3[Bi] = on
  1161.                 term.write("|")
  1162.             else
  1163.                 term.setCursorPos(data3[Bi], Ki)
  1164.                 term.write("|")
  1165.             end
  1166.             term.setBackgroundColor(Zi)
  1167.             term.setTextColor(en)
  1168.             if data3[Bi] - Gi >= 0 then
  1169.                 return data3[Bi] - Gi
  1170.             elseif data3[Bi] - Gi < 0 then
  1171.                 return 0
  1172.             end
  1173.         end
  1174.     end
  1175. end
  1176. function t.sliderVer(nn, sn, hn, rn, dn, ln, un, cn)
  1177.     if nn == "db" then
  1178.         if data10 == nil then
  1179.             return nil
  1180.         else
  1181.             return data10[sn]
  1182.         end
  1183.     end
  1184.     if nn == "setdb" then
  1185.         if data10 == nil then
  1186.             return "no data to edit"
  1187.         else
  1188.             data10[sn] = hn
  1189.             return "value changed too " .. type(hn)
  1190.         end
  1191.     end
  1192.     a(1, nn, "number")
  1193.     a(2, sn, "table")
  1194.     a(3, hn, "number")
  1195.     a(4, rn, "number")
  1196.     a(5, dn, "number")
  1197.     a(6, ln, "number")
  1198.     a(7, un, "string")
  1199.     a(8, cn, "string")
  1200.     if sn[2] == nn or sn[2] == "tout" then
  1201.         if sn ~= nil then
  1202.             local mn = term.getBackgroundColor()
  1203.             local fn = term.getTextColor()
  1204.             term.setBackgroundColor(colors[un])
  1205.             term.setTextColor(colors[cn])
  1206.             term.setCursorPos(rn, dn)
  1207.             for wn = 0, ln do
  1208.                 term.write("\124")
  1209.                 term.setCursorPos(rn, dn - wn)
  1210.             end
  1211.             if data10 == nil then
  1212.                 data10 = {}
  1213.                 for yn = 0, 1000 do
  1214.                     data10[yn] = 0
  1215.                 end
  1216.             end
  1217.             local pn = sn[4]
  1218.             if sn[3] == rn and sn[4] <= dn and sn[4] >= dn - ln + 1 then
  1219.                 term.setCursorPos(rn, pn)
  1220.                 data10[hn] = pn
  1221.                 term.write("\xad")
  1222.             else
  1223.                 term.setCursorPos(rn, data10[hn])
  1224.                 term.write("\xad")
  1225.             end
  1226.             term.setBackgroundColor(mn)
  1227.             term.setTextColor(fn)
  1228.             if data10[hn] - rn >= 0 then
  1229.                 return data10[hn] - rn
  1230.             elseif data10[hn] - rn < 0 then
  1231.                 return 0
  1232.             end
  1233.         end
  1234.     end
  1235. end
  1236. function t.render(vn, bn, gn, kn, qn)
  1237.     a(1, vn, "string")
  1238.     a(2, bn, "number")
  1239.     a(3, gn, "number")
  1240.     a(4, kn, "string")
  1241.     a(5, qn, "string", "number")
  1242.     local jn = term.getBackgroundColor()
  1243.     local xn = term.getTextColor()
  1244.     local zn = {term.getCursorPos()}
  1245.     term.setTextColor(colors[kn])
  1246.     if type(qn) == "string" then
  1247.         term.setBackgroundColor(colors[qn])
  1248.     elseif type(qn) == "number" then
  1249.         term.setBackgroundColor(qn)
  1250.     end
  1251.     term.setCursorPos(bn, gn)
  1252.     term.write(vn)
  1253.     term.setBackgroundColor(jn)
  1254.     term.setTextColor(xn)
  1255.     term.setCursorPos(zn[1], zn[2])
  1256. end
  1257. function t.menu(En, Tn, An, On, In, Nn, Sn, Hn, Rn, Dn, Ln)
  1258.     a(1, En, "number")
  1259.     a(2, Tn, "table")
  1260.     a(3, An, "number")
  1261.     a(4, On, "number")
  1262.     a(5, In, "number")
  1263.     a(6, Nn, "string")
  1264.     a(7, Sn, "string")
  1265.     a(8, Hn, "string")
  1266.     a(9, Rn, "string", "number", "boolean", "nil")
  1267.     a(10, Dn, "boolean")
  1268.     a(11, Ln, "string", "number", "boolean", "nil")
  1269.     if Tn[2] == En or Tn[2] == "tout" then
  1270.         if thisIsUseless == nil then
  1271.             for Un = 0, 1000 do
  1272.                 thisIsUseless = {}
  1273.                 thisIsUseless[Un] = false
  1274.             end
  1275.         end
  1276.         if not thisIsUseless[An] then
  1277.             t.render(Hn, On, In, Nn, oldcol2)
  1278.         end
  1279.         if Tn ~= nil then
  1280.             local Cn = term.getTextColor()
  1281.             local Mn = term.getBackgroundColor()
  1282.             local Fn = #Hn
  1283.             if Tn[1] ~= "timeout" then
  1284.                 if data4 == nil then
  1285.                     data4 = {}
  1286.                     for Wn = 0, 1000 do
  1287.                         data4[Wn] = false
  1288.                     end
  1289.                 end
  1290.                 if data5 == nil then
  1291.                     data5 = {}
  1292.                     for Yn = 0, 1000 do
  1293.                         data5[Yn] = false
  1294.                     end
  1295.                 end
  1296.                 if data6 == nil then
  1297.                     data6 = {}
  1298.                     for Pn = 0, 1000 do
  1299.                         data6[Pn] = false
  1300.                     end
  1301.                 end
  1302.                 if t.API(Tn, On, In, Fn, 1) == true then
  1303.                     data4[An] = Hn
  1304.                     data5[An] = On
  1305.                     data6[An] = In
  1306.                     local function Vn()
  1307.                         for Bn = 1, 500 do
  1308.                             if data4[Bn] ~= false then
  1309.                                 term.setBackgroundColor(Mn)
  1310.                                 term.setCursorPos(data5[Bn], data6[Bn])
  1311.                                 term.setTextColor(colors[Nn])
  1312.                                 term.write(data4[Bn])
  1313.                             end
  1314.                         end
  1315.                     end
  1316.                     Vn()
  1317.                     term.setCursorPos(data5[An], data6[An])
  1318.                     term.setBackgroundColor(colors[Sn])
  1319.                     term.setTextColor(colors[Nn])
  1320.                     term.write(Hn)
  1321.                     term.setTextColor(Cn)
  1322.                     term.setBackgroundColor(Mn)
  1323.                     menuout = Hn
  1324.                     if Rn == nil then
  1325.                         return menuout
  1326.                     else
  1327.                         if Dn == nil or Dn == false then
  1328.                             menuout = Rn
  1329.                             return menuout
  1330.                         else
  1331.                             menuout = {Rn, Ln}
  1332.                             if menuout == nil then
  1333.                                 return 0
  1334.                             end
  1335.                             return menuout
  1336.                         end
  1337.                     end
  1338.                 end
  1339.             end
  1340.         end
  1341.     end
  1342.     thisIsUseless[An] = true
  1343.     if Dn == true then
  1344.         if menuout == nil then
  1345.             menuout = {Rn, "nil"}
  1346.         end
  1347.     end
  1348. end
  1349. function t.menudata()
  1350.     if menuout ~= nil then
  1351.         return menuout
  1352.     else
  1353.         return "no output"
  1354.     end
  1355. end
  1356. function t.bar(us, cs, ms, fs, ws, ys, ps, vs, bs, gs, ks, qs, js, xs, zs)
  1357.     a(1, us, "number")
  1358.     a(2, cs, "number")
  1359.     a(3, ms, "number")
  1360.     a(4, fs, "number")
  1361.     a(5, ws, "number")
  1362.     a(6, ys, "number")
  1363.     a(7, ps, "string")
  1364.     a(8, vs, "string")
  1365.     a(9, bs, "string")
  1366.     a(10, gs, "boolean")
  1367.     a(11, ks, "boolean")
  1368.     a(12, qs, "string")
  1369.     a(13, js, "boolean")
  1370.     a(14, xs, "boolean")
  1371.     a(15, zs, "boolean")
  1372.     if ws == nil or ws < 0 then
  1373.         ws = 0
  1374.     end
  1375.     if js == nil then
  1376.     end
  1377.     if ws ~= nil then
  1378.         oldcol = term.getBackgroundColor()
  1379.         oldcol1 = term.getTextColor()
  1380.         term.setTextColor(colors[bs])
  1381.         local function Es()
  1382.             term.setBackgroundColor(colors[ps])
  1383.             t.fill(us - 1, cs - fs, ms, fs * 2)
  1384.             term.setBackgroundColor(oldcol)
  1385.             xm = term.getBackgroundColor()
  1386.             xb = term.getTextColor()
  1387.             term.setTextColor(xm)
  1388.             term.setBackgroundColor(xb)
  1389.             term.setCursorPos(us - 1, cs - fs)
  1390.             if zs then
  1391.                 term.setBackgroundColor(colors[bs])
  1392.             end
  1393.             if zs then
  1394.                 term.write(string.rep("\x83", ms + 1))
  1395.                 term.setTextColor(xb)
  1396.                 term.setBackgroundColor(xm)
  1397.             else
  1398.                 term.write("\159" .. string.rep("\143", ms - 1))
  1399.                 term.setTextColor(xb)
  1400.                 term.setBackgroundColor(xm)
  1401.                 term.write("\144")
  1402.             end
  1403.             if zs then
  1404.                 term.setBackgroundColor(colors[bs])
  1405.             end
  1406.             term.setCursorPos(us - 1, cs + fs)
  1407.             if zs then
  1408.                 term.write(string.rep("\x8c", ms + 1))
  1409.             else
  1410.                 term.write("\130" .. string.rep("\131", ms - 1) .. "\129")
  1411.             end
  1412.             for Ts = 0, fs * 2 - 2 do
  1413.                 if not zs then
  1414.                     term.setTextColor(xm)
  1415.                     term.setBackgroundColor(xb)
  1416.                 end
  1417.                 term.setCursorPos(us - 1, cs + Ts - fs + 1)
  1418.                 if zs then
  1419.                     term.setBackgroundColor(colors[bs])
  1420.                 end
  1421.                 term.write("\x95")
  1422.                 term.setCursorPos(us - 2 + (ms + 1), cs + Ts - fs + 1)
  1423.                 if not zs then
  1424.                     term.setTextColor(xb)
  1425.                     term.setBackgroundColor(xm)
  1426.                 end
  1427.                 term.write("\x95")
  1428.             end
  1429.         end
  1430.         if xs ~= false then
  1431.             Es()
  1432.         else
  1433.             t.fill(us - 1, cs - fs, ms, fs * 2)
  1434.         end
  1435.         local As = ws / ys * ms
  1436.         local Os = ws / ys * fs
  1437.         local Is = math.ceil(Os)
  1438.         local Ns = Is * 2 - 2
  1439.         local Ss = cs + fs
  1440.         term.setBackgroundColor(colors[vs])
  1441.         if ks == false or ks == nil then
  1442.             t.fill(us, cs - fs + 1, As - 1, fs * 2 - 1)
  1443.         else
  1444.             t.fill(us, Ss - 1 - Ns, ms - 1, Ns + 1)
  1445.         end
  1446.         if gs == true then
  1447.             term.setCursorPos(us, cs)
  1448.             term.setTextColor(colors[bs])
  1449.             if ks == true then
  1450.                 if js then
  1451.                     if ws >= ys / 2 then
  1452.                         term.setBackgroundColor(colors[vs])
  1453.                     else
  1454.                         term.setBackgroundColor(colors[ps])
  1455.                     end
  1456.                 else
  1457.                     if ws >= ys / 2 - ys / fs then
  1458.                         term.setBackgroundColor(colors[vs])
  1459.                     else
  1460.                         term.setBackgroundColor(colors[ps])
  1461.                     end
  1462.                 end
  1463.             elseif ks == false then
  1464.                 term.setCursorPos(us, cs)
  1465.                 term.setTextColor(colors[bs])
  1466.                 if ks == true then
  1467.                     if ws >= 1 then
  1468.                         term.setBackgroundColor(colors[vs])
  1469.                     else
  1470.                         term.setBackgroundColor(colors[ps])
  1471.                     end
  1472.                 end
  1473.             end
  1474.             if js then
  1475.                 term.write(ws .. "/" .. ys)
  1476.                 term.setCursorPos(us, cs + 1)
  1477.                 term.write(qs)
  1478.             else
  1479.                 term.write(ws .. "/" .. ys .. " " .. qs)
  1480.             end
  1481.             term.setBackgroundColor(oldcol)
  1482.             term.setTextColor(oldcol1)
  1483.         end
  1484.         term.setTextColor(oldcol1)
  1485.         term.setBackgroundColor(oldcol)
  1486.     end
  1487. end
  1488. function t.frame(Hs, Rs, Ds, Ls, Us, Cs, Ms)
  1489.     a(1, Hs, "number")
  1490.     a(2, Rs, "number")
  1491.     a(3, Ds, "number")
  1492.     a(4, Ls, "number")
  1493.     a(5, Us, "string")
  1494.     a(6, Cs, "string")
  1495.     a(7, Ms, "boolean", "nil")
  1496.     local Fs = term.getBackgroundColor()
  1497.     local Ws = term.getTextColor()
  1498.     term.setBackgroundColor(colors[Cs])
  1499.     t.fill(Hs - 1, Rs - Ls, Ds, Ls * 2)
  1500.     term.setBackgroundColor(Fs)
  1501.     xm = term.getBackgroundColor()
  1502.     xb = term.getTextColor()
  1503.     term.setTextColor(xm)
  1504.     term.setBackgroundColor(xb)
  1505.     term.setCursorPos(Hs - 1, Rs - Ls)
  1506.     if Ms then
  1507.         term.setBackgroundColor(colors[Us])
  1508.         term.setTextColor(Fs)
  1509.         term.write(string.rep("\x83", Ds + 1))
  1510.         term.setTextColor(xb)
  1511.         term.setBackgroundColor(xm)
  1512.     else
  1513.         term.setTextColor(Fs)
  1514.         term.setBackgroundColor(colors[Us])
  1515.         term.write("\159" .. string.rep("\143", Ds - 1))
  1516.         term.setTextColor(colors[Us])
  1517.         term.setBackgroundColor(Fs)
  1518.         term.write("\144")
  1519.     end
  1520.     term.setCursorPos(Hs - 1, Rs + Ls)
  1521.     if Ms then
  1522.         term.setBackgroundColor(Fs)
  1523.         term.setTextColor(colors[Us])
  1524.         term.write(string.rep("\x8f", Ds + 1))
  1525.         term.setBackgroundColor(colors[Cs])
  1526.         term.setTextColor(colors[Us])
  1527.     else
  1528.         term.write("\130" .. string.rep("\131", Ds - 1) .. "\129")
  1529.     end
  1530.     for Ys = 0, Ls * 2 - 2 do
  1531.         if not Ms then
  1532.             term.setTextColor(xm)
  1533.             term.setBackgroundColor(xb)
  1534.         end
  1535.         term.setCursorPos(Hs - 1, Rs + Ys - Ls + 1)
  1536.         if Ms then
  1537.             term.setBackgroundColor(colors[Us])
  1538.         end
  1539.         term.setBackgroundColor(colors[Us])
  1540.         term.write("\x95")
  1541.         term.setCursorPos(Hs - 2 + (Ds + 1), Rs + Ys - Ls + 1)
  1542.         if not Ms then
  1543.             term.setTextColor(xb)
  1544.             term.setBackgroundColor(xm)
  1545.         end
  1546.         term.setTextColor(colors[Us])
  1547.         term.write("\x95")
  1548.     end
  1549.     term.setBackgroundColor(Fs)
  1550.     term.setTextColor(Ws)
  1551. end
  1552. return {monitor = e, terminal = t}
Add Comment
Please, Sign In to add comment