Advertisement
Guest User

startup

a guest
May 28th, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 39.71 KB | None | 0 0
  1. --[[This is a fix of the original version (https://pastebin.com/knPtJCjb). Thanks to https://pastebin.com/dyre9saS and https://pastebin.com/gyMNUyRb for providing a fix to the clock while I was distracted from this project. I've remade the getTime function to make it work with Timezones again]]
  2. local mon = peripheral.find("monitor")
  3. local core = peripheral.find("draconic_rf_storage")
  4. local tier = 0
  5. local colorShield = colors.white
  6. local colorCore = colors.white
  7. local input, output = peripheral.find("flux_gate")
  8. local limitTransfer = true
  9. local currentControls = "main"
  10. local page = 1
  11. local putLimit = ""
  12. local version = "1.0"
  13. local timediff = 0
  14. local monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31}
  15.  
  16. if fs.exists("logs.cfg") then
  17. else
  18.     file = io.open("logs.cfg", "w")
  19.     file:write("")
  20.     file:close()
  21. end
  22.  
  23. if fs.exists("config.cfg") then
  24. else
  25.     file = io.open("config.cfg", "w")
  26.     file:write("Timezone: 0")
  27.     file:close()
  28. end
  29.  
  30. mon.setTextScale(1)
  31.  
  32. local function fileWrite(path, text)
  33.     local file = io.open(path, "w")
  34.     file:write(text)
  35.     file:close()
  36. end
  37.  
  38. local function fileWriteFromTable(path, t)
  39.     local text = ""
  40.     for _, line in pairs(t) do
  41.         text = text..line.."\n"
  42.     end
  43.     fileWrite(path, text)
  44. end
  45.  
  46. local function fileGetTable(path)
  47.     if fs.exists(path) then
  48.         local file = io.open(path, "r")
  49.         local lines = {}
  50.         local i = 1
  51.         local line = file:read("*l")
  52.         while line ~= nil do
  53.             lines[i] = line
  54.             line = file:read("*l")
  55.             i = i +1
  56.         end
  57.         file:close()
  58.         return lines
  59.     end
  60.     return {}
  61. end
  62.  
  63. local function fileReplaceLine(path, n, text)
  64.     local lines = fileGetTable(path)
  65.     lines[n] = text
  66.     fileWriteFromTable(path, lines)
  67. end
  68.  
  69. local function fileAppend(path, text)
  70.     local file = io.open(path, "a")
  71.     file:write(text.."\n")
  72.     file:close()
  73. end
  74.  
  75. local function fileGetLength(path)
  76.     local file = io.open(path, "r")
  77.     local i = 0
  78.     while file:read("*l") ~= nil do
  79.         i = i +1
  80.     end
  81.     file:close()
  82.     return i
  83. end
  84.  
  85. local function fileGetLines(path, startN, endN)
  86.     local lines = fileGetTable(path)
  87.     local linesOut = {}
  88.     local x = 1
  89.     for i = startN, endN, 1 do
  90.         linesOut[x] = lines[i]
  91.         x = x + 1
  92.     end
  93.     return linesOut
  94. end
  95.  
  96. local function editConfigFile(path,line,text)
  97.     fileReplaceLine(path,line,text)
  98. end
  99.  
  100. local function detectInOutput()
  101.     input, output = peripheral.find("flux_gate")
  102.     --print(input)
  103.     --print(output)
  104.     if core.getTransferPerTick() ~= 0 then
  105.         if core.getTransferPerTick() < 0 then
  106.             output.setSignalLowFlow(0)
  107.             sleep(2)
  108.             if core.getTransferPerTick() >= 0 then
  109.                 --keep it
  110.             else
  111.                 output, input = peripheral.find("flux_gate")
  112.             end
  113.             output.setSignalLowFlow(2147483647)
  114.             input.setSignalLowFlow(2147483647)
  115.         elseif core.getTransferPerTick() > 0 then
  116.             input.setSignalLowFlow(0)
  117.             sleep(2)
  118.             if core.getTransferPerTick() <= 0 then
  119.                 --keep it
  120.             else
  121.                 output, input = peripheral.find("flux_gate")
  122.             end
  123.             output.setSignalLowFlow(2147483647)
  124.             input.setSignalLowFlow(2147483647)
  125.         end
  126.     end
  127. end
  128.  
  129. if peripheral.find("flux_gate") == nil then
  130.     limitTransfer = false
  131. else
  132.     limitTransfer = true
  133.     detectInOutput()
  134. end
  135.  
  136. local function makeNumber2Digits(number)
  137.     strNumber = tostring(number)
  138.     if string.len(strNumber) == 1 then
  139.         return "0" .. strNumber
  140.     else
  141.         return string.sub(strNumber, string.len(strNumber) - 2)
  142.     end
  143. end
  144.  
  145. local function getLogs(path, xPos, yPos)
  146.     local Logs = fileGetLines(path, fileGetLength(path)-5, fileGetLength(path))
  147.     for i = 1, 6, 1 do
  148.         mon.setCursorPos(xPos+2,yPos+1+i)
  149.         mon.write(Logs[i])
  150.     end
  151. end
  152.  
  153. local function addLog(path, time, text)
  154.     fileAppend(path, "["..time.."]")
  155.     fileAppend(path, text)
  156. end
  157.  
  158. local function round(num, idp)
  159.     local mult = 10^(idp or 0)
  160.     return math.floor(num * mult + 0.5) / mult
  161. end
  162.  
  163. local function convertRF(rf)
  164.     rfString = ""
  165.     if rf < 1000 then
  166.         rfString = tostring(rf)
  167.     elseif rf < 1000000 then
  168.         rfString = tostring(round((rf/1000),1)).."k"
  169.     elseif rf < 1000000000 then
  170.         rfString = tostring(round((rf/1000000),1)).."M"
  171.     elseif rf < 1000000000000 then
  172.         rfString = tostring(round((rf/1000000000),1)).."G"
  173.     elseif rf < 1000000000000000 then
  174.         rfString = tostring(round((rf/1000000000000),1)).."T"
  175.     elseif rf < 1000000000000000000 then
  176.         rfString = tostring(round((rf/1000000000000000),1)).."P"
  177.     elseif rf < 1000000000000000000000 then
  178.         rfString = tostring(round((rf/1000000000000000000),1)).."E"
  179.     end
  180.     return(rfString.."RF")
  181. end
  182.  
  183. local function drawL1(xPos, yPos)
  184.     mon.setCursorPos(xPos, yPos)
  185.     mon.setBackgroundColor(colorCore)
  186.     mon.write(" ")
  187.     mon.setCursorPos(xPos, yPos+1)
  188.     mon.write(" ")
  189.     mon.setCursorPos(xPos, yPos+2)
  190.     mon.write(" ")
  191.     mon.setCursorPos(xPos, yPos+3)
  192.     mon.write(" ")
  193.     mon.setCursorPos(xPos, yPos+4)
  194.     mon.setBackgroundColor(colorShield)
  195.     mon.write(" ")
  196.     mon.setCursorPos(xPos, yPos+5)
  197.     mon.setBackgroundColor(colorCore)
  198.     mon.write(" ")
  199.     mon.setCursorPos(xPos, yPos+6)
  200.     mon.write(" ")
  201.     mon.setCursorPos(xPos, yPos+7)
  202.     mon.setBackgroundColor(colorShield)
  203.     mon.write(" ")
  204.     mon.setCursorPos(xPos, yPos+8)
  205.     mon.setBackgroundColor(colorCore)
  206.     mon.write(" ")
  207. end
  208.  
  209. local function drawL2(xPos, yPos)
  210.     mon.setCursorPos(xPos, yPos)
  211.     mon.setBackgroundColor(colorCore)
  212.     mon.write(" ")
  213.     mon.setCursorPos(xPos, yPos+1)
  214.     mon.write(" ")
  215.     mon.setCursorPos(xPos, yPos+2)
  216.     mon.write(" ")
  217.     mon.setCursorPos(xPos, yPos+3)
  218.     mon.write(" ")
  219.     mon.setCursorPos(xPos, yPos+4)
  220.     mon.write(" ")
  221.     mon.setCursorPos(xPos, yPos+5)
  222.     mon.setBackgroundColor(colorShield)
  223.     mon.write(" ")
  224.     mon.setCursorPos(xPos, yPos+6)
  225.     mon.setBackgroundColor(colorCore)
  226.     mon.write(" ")
  227.     mon.setCursorPos(xPos, yPos+7)
  228.     mon.write(" ")
  229.     mon.setCursorPos(xPos, yPos+8)
  230.     mon.write(" ")
  231. end
  232.  
  233. local function drawL3(xPos, yPos)
  234.     mon.setCursorPos(xPos, yPos)
  235.     mon.setBackgroundColor(colorCore)
  236.     mon.write(" ")
  237.     mon.setCursorPos(xPos, yPos+1)
  238.     mon.write(" ")
  239.     mon.setCursorPos(xPos, yPos+2)
  240.     mon.setBackgroundColor(colorShield)
  241.     mon.write(" ")
  242.     mon.setCursorPos(xPos, yPos+3)
  243.     mon.setBackgroundColor(colorCore)
  244.     mon.write(" ")
  245.     mon.setCursorPos(xPos, yPos+4)
  246.     mon.write(" ")
  247.     mon.setCursorPos(xPos, yPos+5)
  248.     mon.write(" ")
  249.     mon.setCursorPos(xPos, yPos+6)
  250.     mon.setBackgroundColor(colorShield)
  251.     mon.write(" ")
  252.     mon.setCursorPos(xPos, yPos+7)
  253.     mon.setBackgroundColor(colorCore)
  254.     mon.write(" ")
  255.     mon.setCursorPos(xPos, yPos+8)
  256.     mon.write(" ")
  257. end
  258.  
  259. local function drawL4(xPos, yPos)
  260.     mon.setCursorPos(xPos, yPos)
  261.     mon.setBackgroundColor(colorCore)
  262.     mon.write(" ")
  263.     mon.setCursorPos(xPos, yPos+1)
  264.     mon.write(" ")
  265.     mon.setCursorPos(xPos, yPos+2)
  266.     mon.write(" ")
  267.     mon.setCursorPos(xPos, yPos+3)
  268.     mon.setBackgroundColor(colorShield)
  269.     mon.write(" ")
  270.     mon.setCursorPos(xPos, yPos+4)
  271.     mon.setBackgroundColor(colorCore)
  272.     mon.write(" ")
  273.     mon.setCursorPos(xPos, yPos+5)
  274.     mon.write(" ")
  275.     mon.setCursorPos(xPos, yPos+6)
  276.     mon.write(" ")
  277.     mon.setCursorPos(xPos, yPos+7)
  278.     mon.setBackgroundColor(colorShield)
  279.     mon.write(" ")
  280.     mon.setCursorPos(xPos, yPos+8)
  281.     mon.setBackgroundColor(colorCore)
  282.     mon.write(" ")
  283. end
  284.  
  285. local function drawL5(xPos, yPos)
  286.     mon.setCursorPos(xPos, yPos)
  287.     mon.setBackgroundColor(colorShield)
  288.     mon.write(" ")
  289.     mon.setCursorPos(xPos, yPos+1)
  290.     mon.setBackgroundColor(colorCore)
  291.     mon.write(" ")
  292.     mon.setCursorPos(xPos, yPos+2)
  293.     mon.write(" ")
  294.     mon.setCursorPos(xPos, yPos+3)
  295.     mon.write(" ")
  296.     mon.setCursorPos(xPos, yPos+4)
  297.     mon.write(" ")
  298.     mon.setCursorPos(xPos, yPos+5)
  299.     mon.write(" ")
  300.     mon.setCursorPos(xPos, yPos+6)
  301.     mon.write(" ")
  302.     mon.setCursorPos(xPos, yPos+7)
  303.     mon.write(" ")
  304.     mon.setCursorPos(xPos, yPos+8)
  305.     mon.write(" ")
  306. end
  307.  
  308. local function drawL6(xPos, yPos)
  309.     mon.setCursorPos(xPos, yPos)
  310.     mon.setBackgroundColor(colorCore)
  311.     mon.write(" ")
  312.     mon.setCursorPos(xPos, yPos+1)
  313.     mon.setBackgroundColor(colorShield)
  314.     mon.write(" ")
  315.     mon.setCursorPos(xPos, yPos+2)
  316.     mon.setBackgroundColor(colorCore)
  317.     mon.write(" ")
  318.     mon.setCursorPos(xPos, yPos+3)
  319.     mon.write(" ")
  320.     mon.setCursorPos(xPos, yPos+4)
  321.     mon.write(" ")
  322.     mon.setCursorPos(xPos, yPos+5)
  323.     mon.setBackgroundColor(colorShield)
  324.     mon.write(" ")
  325.     mon.setCursorPos(xPos, yPos+6)
  326.     mon.setBackgroundColor(colorCore)
  327.     mon.write(" ")
  328.     mon.setCursorPos(xPos, yPos+7)
  329.     mon.write(" ")
  330.     mon.setCursorPos(xPos, yPos+8)
  331.     mon.write(" ")
  332. end
  333.  
  334. local function drawL7(xPos, yPos)
  335.     mon.setCursorPos(xPos, yPos)
  336.     mon.setBackgroundColor(colorCore)
  337.     mon.write(" ")
  338.     mon.setCursorPos(xPos, yPos+1)
  339.     mon.write(" ")
  340.     mon.setCursorPos(xPos, yPos+2)
  341.     mon.write(" ")
  342.     mon.setCursorPos(xPos, yPos+3)
  343.     mon.setBackgroundColor(colorShield)
  344.     mon.write(" ")
  345.     mon.setCursorPos(xPos, yPos+4)
  346.     mon.setBackgroundColor(colorCore)
  347.     mon.write(" ")
  348.     mon.setCursorPos(xPos, yPos+5)
  349.     mon.write(" ")
  350.     mon.setCursorPos(xPos, yPos+6)
  351.     mon.setBackgroundColor(colorShield)
  352.     mon.write(" ")
  353.     mon.setCursorPos(xPos, yPos+7)
  354.     mon.setBackgroundColor(colorCore)
  355.     mon.write(" ")
  356.     mon.setCursorPos(xPos, yPos+8)
  357.     mon.setBackgroundColor(colorShield)
  358.     mon.write(" ")
  359. end
  360.  
  361. local function drawL8(xPos, yPos)
  362.     mon.setCursorPos(xPos, yPos)
  363.     mon.setBackgroundColor(colorCore)
  364.     mon.write(" ")
  365.     mon.setCursorPos(xPos, yPos+1)
  366.     mon.write(" ")
  367.     mon.setCursorPos(xPos, yPos+2)
  368.     mon.write(" ")
  369.     mon.setCursorPos(xPos, yPos+3)
  370.     mon.write(" ")
  371.     mon.setCursorPos(xPos, yPos+4)
  372.     mon.setBackgroundColor(colorShield)
  373.     mon.write(" ")
  374.     mon.setCursorPos(xPos, yPos+5)
  375.     mon.setBackgroundColor(colorCore)
  376.     mon.write(" ")
  377.     mon.setCursorPos(xPos, yPos+6)
  378.     mon.write(" ")
  379.     mon.setCursorPos(xPos, yPos+7)
  380.     mon.write(" ")
  381.     mon.setCursorPos(xPos, yPos+8)
  382.     mon.write(" ")
  383. end
  384.  
  385. local function drawL9(xPos, yPos)
  386.     mon.setCursorPos(xPos, yPos)
  387.     mon.setBackgroundColor(colorCore)
  388.     mon.write(" ")
  389.     mon.setCursorPos(xPos, yPos+1)
  390.     mon.setBackgroundColor(colorShield)
  391.     mon.write(" ")
  392.     mon.setCursorPos(xPos, yPos+2)
  393.     mon.setBackgroundColor(colorCore)
  394.     mon.write(" ")
  395.     mon.setCursorPos(xPos, yPos+3)
  396.     mon.write(" ")
  397.     mon.setCursorPos(xPos, yPos+4)
  398.     mon.write(" ")
  399.     mon.setCursorPos(xPos, yPos+5)
  400.     mon.write(" ")
  401.     mon.setCursorPos(xPos, yPos+6)
  402.     mon.write(" ")
  403.     mon.setCursorPos(xPos, yPos+7)
  404.     mon.setBackgroundColor(colorShield)
  405.     mon.write(" ")
  406.     mon.setCursorPos(xPos, yPos+8)
  407.     mon.setBackgroundColor(colorCore)
  408.     mon.write(" ")
  409. end
  410.  
  411. local function drawL10(xPos, yPos)
  412.     mon.setCursorPos(xPos, yPos)
  413.     mon.setBackgroundColor(colorCore)
  414.     mon.write(" ")
  415.     mon.setCursorPos(xPos, yPos+1)
  416.     mon.write(" ")
  417.     mon.setCursorPos(xPos, yPos+2)
  418.     mon.setBackgroundColor(colorShield)
  419.     mon.write(" ")
  420.     mon.setCursorPos(xPos, yPos+3)
  421.     mon.setBackgroundColor(colorCore)
  422.     mon.write(" ")
  423.     mon.setCursorPos(xPos, yPos+4)
  424.     mon.write(" ")
  425.     mon.setCursorPos(xPos, yPos+5)
  426.     mon.setBackgroundColor(colorShield)
  427.     mon.write(" ")
  428.     mon.setCursorPos(xPos, yPos+6)
  429.     mon.setBackgroundColor(colorCore)
  430.     mon.write(" ")
  431.     mon.setCursorPos(xPos, yPos+7)
  432.     mon.write(" ")
  433.     mon.setCursorPos(xPos, yPos+8)
  434.     mon.setBackgroundColor(colorShield)
  435.     mon.write(" ")
  436. end
  437.  
  438. local function drawL11(xPos, yPos)
  439.     mon.setCursorPos(xPos, yPos)
  440.     mon.setBackgroundColor(colorCore)
  441.     mon.write(" ")
  442.     mon.setCursorPos(xPos, yPos+1)
  443.     mon.write(" ")
  444.     mon.setCursorPos(xPos, yPos+2)
  445.     mon.write(" ")
  446.     mon.setCursorPos(xPos, yPos+3)
  447.     mon.write(" ")
  448.     mon.setCursorPos(xPos, yPos+4)
  449.     mon.write(" ")
  450.     mon.setCursorPos(xPos, yPos+5)
  451.     mon.write(" ")
  452.     mon.setCursorPos(xPos, yPos+6)
  453.     mon.setBackgroundColor(colorShield)
  454.     mon.write(" ")
  455.     mon.setCursorPos(xPos, yPos+7)
  456.     mon.setBackgroundColor(colorCore)
  457.     mon.write(" ")
  458.     mon.setCursorPos(xPos, yPos+8)
  459.     mon.write(" ")
  460. end
  461.  
  462. local function drawL12(xPos, yPos)
  463.     mon.setCursorPos(xPos, yPos)
  464.     mon.setBackgroundColor(colorShield)
  465.     mon.write(" ")
  466.     mon.setCursorPos(xPos, yPos+1)
  467.     mon.setBackgroundColor(colorCore)
  468.     mon.write(" ")
  469.     mon.setCursorPos(xPos, yPos+2)
  470.     mon.write(" ")
  471.     mon.setCursorPos(xPos, yPos+3)
  472.     mon.write(" ")
  473.     mon.setCursorPos(xPos, yPos+4)
  474.     mon.write(" ")
  475.     mon.setCursorPos(xPos, yPos+5)
  476.     mon.write(" ")
  477.     mon.setCursorPos(xPos, yPos+6)
  478.     mon.write(" ")
  479.     mon.setCursorPos(xPos, yPos+7)
  480.     mon.write(" ")
  481.     mon.setCursorPos(xPos, yPos+8)
  482.     mon.write(" ")
  483. end
  484.  
  485. local function drawL13(xPos, yPos)
  486.     mon.setCursorPos(xPos, yPos)
  487.     mon.setBackgroundColor(colorCore)
  488.     mon.write(" ")
  489.     mon.setCursorPos(xPos, yPos+1)
  490.     mon.write(" ")
  491.     mon.setCursorPos(xPos, yPos+2)
  492.     mon.write(" ")
  493.     mon.setCursorPos(xPos, yPos+3)
  494.     mon.setBackgroundColor(colorShield)
  495.     mon.write(" ")
  496.     mon.setCursorPos(xPos, yPos+4)
  497.     mon.setBackgroundColor(colorCore)
  498.     mon.write(" ")
  499.     mon.setCursorPos(xPos, yPos+5)
  500.     mon.write(" ")
  501.     mon.setCursorPos(xPos, yPos+6)
  502.     mon.setBackgroundColor(colorShield)
  503.     mon.write(" ")
  504.     mon.setCursorPos(xPos, yPos+7)
  505.     mon.setBackgroundColor(colorCore)
  506.     mon.write(" ")
  507.     mon.setCursorPos(xPos, yPos+8)
  508.     mon.write(" ")
  509. end
  510.  
  511. local function drawBox(xMin, xMax, yMin, yMax, title)
  512.     mon.setBackgroundColor(colors.gray)
  513.     for xPos = xMin, xMax, 1 do
  514.         mon.setCursorPos(xPos, yMin)
  515.         mon.write(" ")
  516.     end
  517.     for yPos = yMin, yMax, 1 do
  518.         mon.setCursorPos(xMin, yPos)
  519.         mon.write(" ")
  520.         mon.setCursorPos(xMax, yPos)
  521.         mon.write(" ")
  522.     end
  523.     for xPos = xMin, xMax, 1 do
  524.         mon.setCursorPos(xPos, yMax)
  525.         mon.write(" ")
  526.     end
  527.     mon.setCursorPos(xMin+2, yMin)
  528.     mon.setBackgroundColor(colors.black)
  529.     mon.write(" ")
  530.     mon.write(title)
  531.     mon.write(" ")
  532. end
  533.  
  534. local function drawButton(xMin, xMax, yMin, yMax, text1, text2, bcolor)
  535.     mon.setBackgroundColor(bcolor)
  536.     for yPos = yMin, yMax, 1 do
  537.         for xPos = xMin, xMax, 1 do
  538.             mon.setCursorPos(xPos, yPos)
  539.             mon.write(" ")
  540.         end
  541.     end
  542.     mon.setCursorPos(math.floor((((xMax+xMin)/2)+0.5)-string.len(text1)/2),math.floor(((yMax+yMin)/2)))
  543.     mon.write(text1)
  544.     if text2 == nil then
  545.     else
  546.         mon.setCursorPos(math.floor((((xMax+xMin)/2)+0.5)-string.len(text2)/2),math.floor(((yMax+yMin)/2)+0.5))
  547.         mon.write(text2)
  548.     end
  549.     mon.setBackgroundColor(colors.black)
  550. end
  551.  
  552. local function drawClear(xMin, xMax, yMin, yMax)
  553. mon.setBackgroundColor(colors.black)
  554.     for yPos = yMin, yMax, 1 do
  555.         for xPos = xMin, xMax, 1 do
  556.             mon.setCursorPos(xPos, yPos)
  557.             mon.write(" ")
  558.         end
  559.     end
  560. end
  561.  
  562. local function drawNumpad(xPos ,yPos)
  563.     mon.setCursorPos(xPos+2,yPos+4)
  564.     mon.setBackgroundColor(colors.lightGray)
  565.     mon.write(" 1 ")
  566.     mon.setBackgroundColor(colors.gray)
  567.     mon.write(" ")
  568.     mon.setCursorPos(xPos+6,yPos+4)
  569.     mon.setBackgroundColor(colors.lightGray)
  570.     mon.write(" 2 ")
  571.     mon.setBackgroundColor(colors.gray)
  572.     mon.write(" ")
  573.     mon.setCursorPos(xPos+10,yPos+4)
  574.     mon.setBackgroundColor(colors.lightGray)
  575.     mon.write(" 3 ")
  576.     mon.setCursorPos(xPos+2,yPos+5)
  577.     mon.setBackgroundColor(colors.lightGray)
  578.     mon.write(" 4 ")
  579.     mon.setBackgroundColor(colors.gray)
  580.     mon.write(" ")
  581.     mon.setCursorPos(xPos+6,yPos+5)
  582.     mon.setBackgroundColor(colors.lightGray)
  583.     mon.write(" 5 ")
  584.     mon.setBackgroundColor(colors.gray)
  585.     mon.write(" ")
  586.     mon.setCursorPos(xPos+10,yPos+5)
  587.     mon.setBackgroundColor(colors.lightGray)
  588.     mon.write(" 6 ")
  589.     mon.setCursorPos(xPos+2,yPos+6)
  590.     mon.setBackgroundColor(colors.lightGray)
  591.     mon.write(" 7 ")
  592.     mon.setBackgroundColor(colors.gray)
  593.     mon.write(" ")
  594.     mon.setCursorPos(xPos+6,yPos+6)
  595.     mon.setBackgroundColor(colors.lightGray)
  596.     mon.write(" 8 ")
  597.     mon.setBackgroundColor(colors.gray)
  598.     mon.write(" ")
  599.     mon.setCursorPos(xPos+10,yPos+6)
  600.     mon.setBackgroundColor(colors.lightGray)
  601.     mon.write(" 9 ")
  602.     mon.setCursorPos(xPos+2,yPos+7)
  603.     mon.setBackgroundColor(colors.red)
  604.     mon.write(" < ")
  605.     mon.setBackgroundColor(colors.gray)
  606.     mon.write(" ")
  607.     mon.setCursorPos(xPos+6,yPos+7)
  608.     mon.setBackgroundColor(colors.lightGray)
  609.     mon.write(" 0 ")
  610.     mon.setBackgroundColor(colors.gray)
  611.     mon.write(" ")
  612.     mon.setCursorPos(xPos+10,yPos+7)
  613.     mon.setBackgroundColor(colors.red)
  614.     mon.write(" X ")
  615.     mon.setCursorPos(xPos+16,yPos+5)
  616.     mon.setBackgroundColor(colors.lime)
  617.     mon.write(" Apply")
  618.     mon.setCursorPos(xPos+16,yPos+7)
  619.     mon.setBackgroundColor(colors.red)
  620.     mon.write("Cancel")
  621.     mon.setBackgroundColor(colors.black)
  622. end
  623. local function drawControls(xPos, yPos)
  624.     if currentControls == "main" then
  625.         --drawClear(xPos+1,xPos+22,yPos+1,yPos+8)
  626.         if limitTransfer == false then
  627.             drawButton(xPos+2,xPos+9,yPos+2,yPos+3,"Edit","InputMax",colors.gray)
  628.             drawButton(xPos+13,xPos+21,yPos+2,yPos+3,"Edit","OutputMax",colors.gray)
  629.         else
  630.             drawButton(xPos+2,xPos+9,yPos+2,yPos+3,"Edit","InputMax",colors.lime)
  631.             drawButton(xPos+13,xPos+21,yPos+2,yPos+3,"Edit","OutputMax",colors.red)
  632.         end
  633.         drawButton(xPos+2,xPos+9,yPos+6,yPos+7,"Edit","Config",colorCore)
  634.         drawButton(xPos+13,xPos+21,yPos+6,yPos+7,"No Use","Yet",colors.gray)
  635.     elseif currentControls == "editInput" or currentControls == "editOutput" then
  636.         --drawClear(xPos+1,xPos+22,yPos+1,yPos+8)
  637.         mon.setCursorPos(xPos+2,yPos+2)
  638.         if currentControls == "editInput" then
  639.             mon.write("Edit Max Input Rate")
  640.         else
  641.             mon.write("Edit Max Output Rate")
  642.         end
  643.         mon.setCursorPos(xPos+2,yPos+3)
  644.         mon.setBackgroundColor(colors.gray)
  645.         mon.write("___________")
  646.         if string.len(putLimit) >= 11 then
  647.                 putLimit = string.sub(putLimit,string.len(putLimit)-10)
  648.         end
  649.         if putLimit ~= "" then
  650.             if tonumber(putLimit) <= 2147483647 then
  651.                 mon.setCursorPos(xPos+13-string.len(putLimit),yPos+3)
  652.                 mon.write(putLimit)
  653.                 putLimitNum = tonumber(putLimit)
  654.                 mon.setBackgroundColor(colors.black)
  655.                 fix = 0
  656.                 if putLimitNum < 1000 then
  657.                     if string.len(putLimit) <= 3 then
  658.                         mon.setCursorPos(xPos+22-string.len(putLimit)-2,yPos+3)
  659.                         mon.write(putLimit)
  660.                     else
  661.                         mon.setCursorPos(xPos+22-4-2,yPos+3)
  662.                         mon.write(string.sub(putLimit,string.len(putLimit)-2))
  663.                     end
  664.                 elseif putLimitNum < 1000000 then
  665.                         if (round((putLimitNum/1000),1)*10)/(round((putLimitNum/1000),0)) == 10 then
  666.                             fix = 2
  667.                         end
  668.                     mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000),1)))-3-fix,yPos+3)
  669.                     mon.write(round((putLimitNum/1000),1))
  670.                     mon.write("k")
  671.                 elseif putLimitNum < 1000000000 then
  672.                         --if putLimitNum == 1000000*i or putLimitNum == 10000000*i or putLimitNum == 100000000*i then
  673.                         if (round((putLimitNum/1000000),1)*10)/(round((putLimitNum/1000000),0)) == 10 then
  674.                             fix = 2
  675.                         end
  676.                     mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000000),1)))-3-fix,yPos+3)
  677.                     mon.write(round((putLimitNum/1000000),1))
  678.                     mon.write("M")
  679.                 elseif putLimitNum < 1000000000000 then
  680.                         if (round((putLimitNum/1000000000),1)*10)/(round((putLimitNum/1000000000),0)) == 10 then
  681.                             fix = 2
  682.                         end
  683.                     mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000000000),1)))-3-fix,yPos+3)
  684.                     mon.write(round((putLimitNum/1000000000),1))
  685.                     mon.write("G")
  686.                 end
  687.                 mon.write("RF")
  688.             else
  689.                 putLimit = "2147483647"
  690.                 mon.setCursorPos(xPos+13-string.len(putLimit),yPos+3)
  691.                 mon.write(putLimit)
  692.                 mon.setCursorPos(xPos+22-6,yPos+3)
  693.                 mon.setBackgroundColor(colors.black)
  694.                 mon.write("2.1GRF")
  695.                 mon.setCursorPos(xPos+22-6,yPos+4)
  696.                 mon.write("(max)")
  697.                
  698.             end
  699.            
  700.         end
  701.         drawNumpad(xPos, yPos)
  702.     elseif currentControls == "editOutput" then
  703.     elseif currentControls == "editConfig" then
  704.         mon.setCursorPos(xPos+2,yPos+2)
  705.         mon.write("Edit Config")
  706.         if limitTransfer == true then
  707.             drawButton(xPos+2,xPos+10,yPos+3,yPos+4,"Detect","Flux_Gate",colorCore)
  708.         else
  709.             drawButton(xPos+2,xPos+10,yPos+3,yPos+4,"Detect","Flux_Gate",colors.gray)
  710.         end
  711.         drawButton(xPos+14,xPos+21,yPos+3,yPos+4,"Edit","Timezone",colorCore)
  712.         mon.setCursorPos(xPos+16,yPos+7)
  713.         mon.setBackgroundColor(colors.red)
  714.         mon.write("Cancel")
  715.         mon.setCursorPos(xPos+2,yPos+7)
  716.         mon.setBackgroundColor(colors.gray)
  717.         mon.write("Prev")
  718.         mon.setCursorPos(xPos+7,yPos+7)
  719.         mon.write("Next")
  720.         mon.setBackgroundColor(colors.black)
  721.     elseif currentControls == "editTimezone" then
  722.         mon.setCursorPos(xPos+2,yPos+2)
  723.         mon.write("Type Differenz")
  724.         mon.setCursorPos(xPos+5,yPos+4)
  725.         mon.setBackgroundColor(colors.red)
  726.         mon.write(" -1 ")
  727.         mon.setBackgroundColor(colors.lightGray)
  728.         mon.write(" ")
  729.         mon.setBackgroundColor(colors.gray)
  730.         mon.write("   ")
  731.         if timediff >= -12 and timediff <= 12 then
  732.         elseif timediff < -12 then
  733.             timediff = -12
  734.         elseif timediff > 12 then
  735.             timediff = 12
  736.         end
  737.         mon.setCursorPos(xPos+13-string.len(tostring(timediff)),yPos+4)
  738.         mon.setBackgroundColor(colors.gray)
  739.         mon.write(tostring(timediff))
  740.         mon.setBackgroundColor(colors.lightGray)
  741.         mon.write(" ")
  742.         mon.setBackgroundColor(colors.lime)
  743.         mon.write(" +1 ")
  744.         mon.setCursorPos(xPos+9,yPos+7)
  745.         mon.setBackgroundColor(colors.red)
  746.         mon.write("Cancel")
  747.         mon.setBackgroundColor(colors.black)
  748.         mon.write(" ")
  749.         mon.setBackgroundColor(colors.lime)
  750.         mon.write(" Apply")
  751.         mon.setBackgroundColor(colors.black)
  752.     end
  753. end
  754.  
  755. local function drawDetails(xPos, yPos)
  756.     energyStored = core.getEnergyStored()
  757.     energyMax = core.getMaxEnergyStored()
  758.     energyTransfer = core.getTransferPerTick()
  759.     if limitTransfer == true then
  760.         inputRate = input.getFlow()
  761.         outputRate = output.getFlow()
  762.     end
  763.     mon.setCursorPos(xPos, yPos)
  764.     if energyMax < 50000000 then
  765.         tier = 1
  766.     elseif energyMax < 300000000 then
  767.         tier = 2
  768.     elseif energyMax < 2000000000 then
  769.         tier = 3
  770.     elseif energyMax < 10000000000 then
  771.         tier = 4
  772.     elseif energyMax < 50000000000 then
  773.         tier = 5
  774.     elseif energyMax < 400000000000 then
  775.         tier = 6
  776.     elseif energyMax < 3000000000000 then
  777.         tier = 7
  778.     else
  779.         tier = 8
  780.     end
  781.     mon.write("Tier: ")
  782.     mon.write(tier)
  783.     mon.setCursorPos(xPos+7, yPos)
  784.     mon.write("  ")
  785.     mon.setCursorPos(xPos, yPos+1)
  786.     mon.write("Stored: ")
  787.     if energyStored < 1000 then
  788.         mon.write(energyStored)
  789.     elseif energyStored < 1000000 then
  790.         mon.write(round((energyStored/1000),1))
  791.         mon.write("k")
  792.     elseif energyStored < 1000000000 then
  793.         mon.write(round((energyStored/1000000),1))
  794.         mon.write("M")
  795.     elseif energyStored < 1000000000000 then
  796.         mon.write(round((energyStored/1000000000),1))
  797.         mon.write("G")
  798.     elseif energyStored < 1000000000000000 then
  799.         mon.write(round((energyStored/1000000000000),1))
  800.         mon.write("T")
  801.     elseif energyStored < 1000000000000000000 then
  802.         mon.write(round((energyStored/1000000000000000),1))
  803.         mon.write("P")
  804.     elseif energyStored < 1000000000000000000000 then
  805.         mon.write(round((energyStored/1000000000000000000),1))
  806.         mon.write("E")
  807.     end
  808.     mon.write("RF")
  809.     mon.write("/")
  810.     if energyMax < 1000 then
  811.         mon.write(energyMax)
  812.     elseif energyMax < 1000000 then
  813.         mon.write(round((energyMax/1000),1))
  814.         mon.write("k")
  815.     elseif energyMax < 1000000000 then
  816.         mon.write(round((energyMax/1000000),1))
  817.         mon.write("M")
  818.     elseif energyMax < 1000000000000 then
  819.         mon.write(round((energyMax/1000000000),1))
  820.         mon.write("G")
  821.     elseif energyMax < 1000000000000000 then
  822.         mon.write(round((energyMax/1000000000000),1))
  823.         mon.write("T")
  824.     elseif energyMax < 1000000000000000000 then
  825.         mon.write(round((energyMax/1000000000000000 ),1))
  826.         mon.write("P")
  827.     elseif energyMax < 1000000000000000000000 then
  828.         mon.write(round((energyMax/1000000000000000000),1))
  829.         mon.write("E")
  830.     end
  831.     mon.write("RF")
  832.     mon.setCursorPos(xPos, yPos+2)
  833.     mon.setBackgroundColor(colors.lightGray)
  834.     for l = 1, 20, 1 do
  835.         mon.write(" ")
  836.     end
  837.     mon.setCursorPos(xPos, yPos+2)
  838.     mon.setBackgroundColor(colors.lime)
  839.     for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do
  840.         mon.write(" ")
  841.     end
  842.     mon.setCursorPos(xPos, yPos+3)
  843.     mon.setBackgroundColor(colors.lightGray)
  844.     for l = 1, 20, 1 do
  845.         mon.write(" ")
  846.     end
  847.     mon.setCursorPos(xPos, yPos+3)
  848.     mon.setBackgroundColor(colors.lime)
  849.     for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do
  850.         mon.write(" ")
  851.     end
  852.     mon.setBackgroundColor(colors.black)
  853.     mon.setCursorPos(xPos, yPos+4)
  854.     mon.write("                      ")
  855.     if string.len(tostring(round((energyStored/energyMax)*100))) == 1 then
  856.         if round((energyStored/energyMax)*100) <= 10 then
  857.             mon.setCursorPos(xPos, yPos+4)
  858.             mon.write(round((energyStored/energyMax)*100))
  859.             mon.setCursorPos(xPos+1, yPos+4)
  860.             mon.write("% ")
  861.         else
  862.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5), yPos+4)
  863.             mon.write(round((energyStored/energyMax)*100))
  864.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5)+1, yPos+4)
  865.             mon.write("% ")
  866.         end
  867.     elseif string.len(tostring(round((energyStored/energyMax)*100))) == 2 then
  868.         if round((energyStored/energyMax)*100) <= 15 then
  869.             mon.setCursorPos(xPos, yPos+4)
  870.             mon.write(round((energyStored/energyMax)*100))
  871.             mon.setCursorPos(xPos+2, yPos+4)
  872.             mon.write("% ")
  873.         else
  874.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5), yPos+4)
  875.             mon.write(round((energyStored/energyMax)*100))
  876.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5)+2, yPos+4)
  877.             mon.write("% ")
  878.         end
  879.     elseif string.len(tostring(round((energyStored/energyMax)*100))) == 3 then
  880.         if round((energyStored/energyMax)*100) <= 20 then
  881.             mon.setCursorPos(xPos, yPos+4)
  882.             mon.write(round((energyStored/energyMax)*100))
  883.             mon.setCursorPos(xPos+3, yPos+4)
  884.             mon.write("% ")
  885.         else
  886.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5), yPos+4)
  887.             mon.write(round((energyStored/energyMax)*100))
  888.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5)+3, yPos+4)
  889.             mon.write("% ")
  890.         end
  891.     end
  892.     mon.setCursorPos(xPos, yPos+5)
  893.     mon.write("InputMax:")
  894.     mon.setCursorPos(xPos, yPos+6)
  895.     mon.write("         ")
  896.     mon.setCursorPos(xPos, yPos+6)
  897.     mon.setTextColor(colors.lime)
  898.     if limitTransfer == true then
  899.         if inputRate == 0 then
  900.             mon.setTextColor(colors.red)
  901.         end
  902.         if inputRate < 1000 then
  903.             mon.write(inputRate)
  904.         elseif inputRate < 1000000 then
  905.             mon.write(round((inputRate/1000),1))
  906.             mon.write("k")
  907.         elseif inputRate < 1000000000 then
  908.             mon.write(round((inputRate/1000000),1))
  909.             mon.write("M")
  910.         elseif inputRate < 1000000000000 then
  911.             mon.write(round((inputRate/1000000000),1))
  912.             mon.write("G")
  913.         elseif inputRate < 1000000000000000 then
  914.             mon.write(round((inputRate/1000000000000),1))
  915.             mon.write("T")
  916.         elseif inputRate < 1000000000000000000 then
  917.             mon.write(round((inputRate/1000000000000000 ),1))
  918.             mon.write("P")
  919.         elseif inputRate < 1000000000000000000000 then
  920.             mon.write(round((inputRate/1000000000000000000),1))
  921.             mon.write("E")
  922.         end
  923.         mon.write("RF")
  924.     else
  925.         mon.write("INFINITE")
  926.     end
  927.     mon.setTextColor(colors.white)
  928.     mon.setCursorPos(xPos+12, yPos+5)
  929.     mon.write("OutputMax:")
  930.     mon.setCursorPos(xPos+12, yPos+6)
  931.     mon.write("         ")
  932.     mon.setTextColor(colors.red)
  933.     mon.setCursorPos(xPos+12, yPos+6)
  934.     if limitTransfer == true then
  935.         if outputRate < 1000 then
  936.             mon.write(outputRate)
  937.         elseif outputRate < 1000000 then
  938.             mon.write(round((outputRate/1000),1))
  939.             mon.write("k")
  940.         elseif outputRate < 1000000000 then
  941.             mon.write(round((outputRate/1000000),1))
  942.             mon.write("M")
  943.         elseif outputRate < 1000000000000 then
  944.             mon.write(round((outputRate/1000000000),1))
  945.             mon.write("G")
  946.         elseif outputRate < 1000000000000000 then
  947.             mon.write(round((outputRate/1000000000000),1))
  948.             mon.write("T")
  949.         elseif outputRate < 1000000000000000000 then
  950.             mon.write(round((outputRate/1000000000000000),1))
  951.             mon.write("P")
  952.         elseif outputRate < 1000000000000000000000 then
  953.             mon.write(round((outputRate/1000000000000000000),1))
  954.             mon.write("E")
  955.         end
  956.         mon.write("RF")
  957.     else
  958.         mon.write("INFINITE")
  959.     end
  960.     mon.setTextColor(colors.white)
  961.     mon.setCursorPos(xPos, yPos+7)
  962.     mon.write("Transfer:")
  963.     mon.setCursorPos(xPos, yPos+8)
  964.     if energyTransfer < 0 then
  965.         mon.setTextColor(colors.red)
  966.         if energyTransfer*(-1) < 1000 then
  967.             mon.write(energyTransfer)
  968.         elseif energyTransfer*(-1) < 1000000 then
  969.             mon.write(round((energyTransfer/1000),1))
  970.             mon.write("k")
  971.         elseif energyTransfer*(-1) < 1000000000 then
  972.             mon.write(round((energyTransfer/1000000),1))
  973.             mon.write("M")
  974.         elseif energyTransfer*(-1) < 1000000000000 then
  975.             mon.write(round((energyTransfer/1000000000),1))
  976.             mon.write("G")
  977.         elseif energyTransfer*(-1) < 1000000000000000 then
  978.             mon.write(round((energyTransfer/1000000000000),1))
  979.             mon.write("T")
  980.         elseif energyTransfer*(-1) < 1000000000000000000 then
  981.             mon.write(round((energyTransfer/1000000000000000),1))
  982.             mon.write("P")
  983.         elseif energyTransfer*(-1) < 1000000000000000000000 then
  984.             mon.write(round((energyTransfer/1000000000000000000),1))
  985.             mon.write("E")
  986.         end
  987.     elseif energyTransfer == 0 then
  988.         mon.setTextColor(colors.red)
  989.         mon.write("0")
  990.     else
  991.         mon.setTextColor(colors.lime)
  992.         if energyTransfer < 1000 then
  993.             mon.write(energyTransfer)
  994.         elseif energyTransfer < 1000000 then
  995.             mon.write(round((energyTransfer/1000),1))
  996.             mon.write("k")
  997.         elseif energyTransfer < 1000000000 then
  998.             mon.write(round((energyTransfer/1000000),1))
  999.             mon.write("M")
  1000.         elseif energyTransfer < 1000000000000 then
  1001.             mon.write(round((energyTransfer/1000000000),1))
  1002.             mon.write("G")
  1003.         elseif energyTransfer < 1000000000000000 then
  1004.             mon.write(round((energyTransfer/1000000000000),1))
  1005.             mon.write("T")
  1006.         elseif energyTransfer < 1000000000000000000 then
  1007.             mon.write(round((energyTransfer/1000000000000000),1))
  1008.             mon.write("P")
  1009.         elseif energyTransfer < 1000000000000000000000 then
  1010.             mon.write(round((energyTransfer/1000000000000000000),1))
  1011.             mon.write("E")
  1012.         end
  1013.     end
  1014.     mon.write("RF")
  1015.     mon.setTextColor(colors.white)
  1016.     mon.setCursorPos(xPos+12, yPos+7)
  1017.     mon.write("Limited:")
  1018.     mon.setCursorPos(xPos+12, yPos+8)
  1019.     if limitTransfer == true then
  1020.         mon.setTextColor(colors.lime)
  1021.         mon.write("On")
  1022.     else
  1023.         mon.setTextColor(colors.red)
  1024.         mon.write("Off")
  1025.     end
  1026.     mon.setTextColor(colors.white)
  1027. end
  1028.  
  1029. local function drawAll()   
  1030.     while true do
  1031.         mon.clear()
  1032.         versionText = "Version "..version.." by Game4Freak"
  1033.         verPos = 51 - string.len(versionText)
  1034.         mon.setCursorPos(verPos,26)
  1035.         mon.setTextColor(colors.gray)
  1036.         mon.write(versionText)
  1037.         mon.setTextColor(colors.white)
  1038.         drawBox(2,20,2,14,"ENERGY CORE")
  1039.         drawBox(22,49,2,14,"DETAILS")
  1040.         drawBox(2,24,16,25,"LOGS")
  1041.         drawBox(26,49,16,25,"CONTROLS")
  1042.         yPos = 4
  1043.         xMin = 5
  1044.         for xPos = xMin, xMin+12, 1 do
  1045.             drawDetails(24,4)
  1046.             drawControls(26,16)
  1047.             getLogs("logs.cfg",2,16)
  1048.             if tier <= 7 then
  1049.                 colorShield = colors.lightBlue
  1050.                 colorCore = colors.cyan
  1051.             else
  1052.                 colorShield = colors.yellow
  1053.                 colorCore = colors.orange
  1054.             end
  1055.             xPos1 = xPos
  1056.             if xPos1 >= xMin+13 then
  1057.                 xPos1a = xPos1 - 13
  1058.                 drawL1(xPos1a, yPos)
  1059.             else
  1060.                 drawL1(xPos1, yPos)
  1061.             end
  1062.             xPos2 = xPos + 1
  1063.             if xPos2 >= xMin+13 then
  1064.                 xPos2a = xPos2 - 13
  1065.                 drawL2(xPos2a, yPos)
  1066.             else
  1067.                 drawL2(xPos2, yPos)
  1068.             end
  1069.             xPos3 = xPos + 2
  1070.             if xPos3 >= xMin+13 then
  1071.                 xPos3a = xPos3 - 13
  1072.                 drawL3(xPos3a, yPos)
  1073.             else
  1074.                 drawL3(xPos3, yPos)
  1075.             end
  1076.             xPos4 = xPos + 3
  1077.             if xPos4 >= xMin+13 then
  1078.                 xPos4a = xPos4 - 13
  1079.                 drawL4(xPos4a, yPos)
  1080.             else
  1081.                 drawL4(xPos4, yPos)
  1082.             end
  1083.             xPos5 = xPos + 4
  1084.             if xPos5 >= xMin+13 then
  1085.                 xPos5a = xPos5 - 13
  1086.                 drawL5(xPos5a, yPos)
  1087.             else
  1088.                 drawL5(xPos5, yPos)
  1089.             end
  1090.             xPos6 = xPos + 5
  1091.             if xPos6 >= xMin+13 then
  1092.                 xPos6a = xPos6 - 13
  1093.                 drawL6(xPos6a, yPos)
  1094.             else
  1095.                 drawL6(xPos6, yPos)
  1096.             end
  1097.             xPos7 = xPos + 6
  1098.             if xPos7 >= xMin+13 then
  1099.                 xPos7a = xPos7 - 13
  1100.                 drawL7(xPos7a, yPos)
  1101.             else
  1102.                 drawL7(xPos7, yPos)
  1103.             end
  1104.             xPos8 = xPos + 7
  1105.             if xPos8 >= xMin+13 then
  1106.                 xPos8a = xPos8 - 13
  1107.                 drawL8(xPos8a, yPos)
  1108.             else
  1109.                 drawL8(xPos8, yPos)
  1110.             end
  1111.             xPos9 = xPos + 8
  1112.             if xPos9 >= xMin+13 then
  1113.                 xPos9a = xPos9 - 13
  1114.                 drawL9(xPos9a, yPos)
  1115.             else
  1116.                 drawL9(xPos9, yPos)
  1117.             end
  1118.             xPos10 = xPos + 9
  1119.             if xPos10 >= xMin+13 then
  1120.                 xPos10a = xPos10 - 13
  1121.                 drawL10(xPos10a, yPos)
  1122.             else
  1123.                 drawL10(xPos10, yPos)
  1124.             end
  1125.             xPos11 = xPos + 10
  1126.             if xPos11 >= xMin+13 then
  1127.                 xPos11a = xPos11 - 13
  1128.                 drawL11(xPos11a, yPos)
  1129.             else
  1130.                 drawL11(xPos11, yPos)
  1131.             end
  1132.             xPos12 = xPos + 11
  1133.             if xPos12 >= xMin+13 then
  1134.                 xPos12a = xPos12 - 13
  1135.                 drawL12(xPos12a, yPos)
  1136.             else
  1137.                 drawL12(xPos12, yPos)
  1138.             end
  1139.             xPos13 = xPos + 12
  1140.             if xPos13 >= xMin+13 then
  1141.                 xPos13a = xPos13 - 13
  1142.                 drawL13(xPos13a, yPos)
  1143.             else
  1144.                 drawL13(xPos13, yPos)
  1145.             end
  1146.             mon.setBackgroundColor(colors.black)
  1147.             mon.setCursorPos(xMin, yPos)
  1148.             mon.write("   ")
  1149.             mon.setCursorPos(xMin+10, yPos)
  1150.             mon.write("   ")
  1151.             mon.setCursorPos(xMin, yPos+1)
  1152.             mon.write(" ")
  1153.             mon.setCursorPos(xMin+12, yPos+1)
  1154.             mon.write(" ")
  1155.             mon.setCursorPos(xMin, yPos+7)
  1156.             mon.write(" ")
  1157.             mon.setCursorPos(xMin+12, yPos+7)
  1158.             mon.write(" ")
  1159.             mon.setCursorPos(xMin, yPos+8)
  1160.             mon.write("   ")
  1161.             mon.setCursorPos(xMin+10, yPos+8)
  1162.             mon.write("   ")
  1163.             sleep(1)
  1164.         end
  1165.     end
  1166. end
  1167.  
  1168. local function clickListener()
  1169.     event, side, xCPos, yCPos = os.pullEvent("monitor_touch")
  1170.     if xCPos == 1 and yCPos == 1 then
  1171.         mon.setCursorPos(1,1)
  1172.         mon.write("Click!")
  1173.         sleep(1)
  1174.         mon.write("      ")
  1175.     end
  1176.     if currentControls == "main" then
  1177.         if xCPos >= 28 and xCPos <= 35 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1178.             drawClear(27,48,17,24)
  1179.             currentControls = "editInput"
  1180.         elseif xCPos >= 39 and xCPos <= 47 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1181.             drawClear(27,48,17,24)
  1182.             currentControls = "editOutput"
  1183.         elseif xCPos >= 28 and xCPos <= 35 and yCPos >= 22 and yCPos <= 23 then
  1184.             drawClear(27,48,17,24)
  1185.             currentControls = "editConfig"
  1186.         end
  1187.     elseif currentControls == "editInput" or currentControls == "editOutput" then
  1188.         if xCPos >= 28 and xCPos <= 30 and yCPos == 20 then
  1189.             mon.setCursorPos(28,20)
  1190.             mon.setBackgroundColor(colors.gray)
  1191.             mon.write(" 1 ")
  1192.             putLimit = putLimit .. "1"
  1193.             sleep(0.2)
  1194.             mon.setCursorPos(28,20)
  1195.             mon.setBackgroundColor(colors.lightGray)
  1196.             mon.write(" 1 ")
  1197.             mon.setBackgroundColor(1,1)
  1198.             mon.setBackgroundColor(colors.black)
  1199.             mon.write(" ")
  1200.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 20 then
  1201.             mon.setCursorPos(32,20)
  1202.             mon.setBackgroundColor(colors.gray)
  1203.             mon.write(" 2 ")
  1204.             putLimit = putLimit .. "2"
  1205.             sleep(0.2)
  1206.             mon.setCursorPos(32,20)
  1207.             mon.setBackgroundColor(colors.lightGray)
  1208.             mon.write(" 2 ")
  1209.             mon.setBackgroundColor(1,1)
  1210.             mon.setBackgroundColor(colors.black)
  1211.             mon.write(" ")
  1212.             mon.write(" ")
  1213.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 20 then
  1214.             mon.setCursorPos(36,20)
  1215.             mon.setBackgroundColor(colors.gray)
  1216.             mon.write(" 3 ")
  1217.             putLimit = putLimit.."3"
  1218.             sleep(0.2)
  1219.             mon.setCursorPos(36,20)
  1220.             mon.setBackgroundColor(colors.lightGray)
  1221.             mon.write(" 3 ")
  1222.             mon.setBackgroundColor(1,1)
  1223.             mon.setBackgroundColor(colors.black)
  1224.             mon.write(" ")
  1225.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 21 then
  1226.             mon.setCursorPos(28,21)
  1227.             mon.setBackgroundColor(colors.gray)
  1228.             mon.write(" 4 ")
  1229.             putLimit = putLimit.."4"
  1230.             sleep(0.2)
  1231.             mon.setCursorPos(28,21)
  1232.             mon.setBackgroundColor(colors.lightGray)
  1233.             mon.write(" 4 ")
  1234.             mon.setBackgroundColor(1,1)
  1235.             mon.setBackgroundColor(colors.black)
  1236.             mon.write(" ")
  1237.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 21 then
  1238.             mon.setCursorPos(32,21)
  1239.             mon.setBackgroundColor(colors.gray)
  1240.             mon.write(" 5 ")
  1241.             putLimit = putLimit.."5"
  1242.             sleep(0.2)
  1243.             mon.setCursorPos(32,21)
  1244.             mon.setBackgroundColor(colors.lightGray)
  1245.             mon.write(" 5 ")
  1246.             mon.setBackgroundColor(1,1)
  1247.             mon.setBackgroundColor(colors.black)
  1248.             mon.write(" ")
  1249.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 21 then
  1250.             mon.setCursorPos(36,21)
  1251.             mon.setBackgroundColor(colors.gray)
  1252.             mon.write(" 6 ")
  1253.             putLimit = putLimit.."6"
  1254.             sleep(0.2)
  1255.             mon.setCursorPos(36,21)
  1256.             mon.setBackgroundColor(colors.lightGray)
  1257.             mon.write(" 6 ")
  1258.             mon.setBackgroundColor(1,1)
  1259.             mon.setBackgroundColor(colors.black)
  1260.             mon.write(" ")
  1261.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 22 then
  1262.             mon.setCursorPos(28,22)
  1263.             mon.setBackgroundColor(colors.gray)
  1264.             mon.write(" 7 ")
  1265.             putLimit = putLimit.."7"
  1266.             sleep(0.2)
  1267.             mon.setCursorPos(28,22)
  1268.             mon.setBackgroundColor(colors.lightGray)
  1269.             mon.write(" 7 ")
  1270.             mon.setBackgroundColor(1,1)
  1271.             mon.setBackgroundColor(colors.black)
  1272.             mon.write(" ")
  1273.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 22 then
  1274.             mon.setCursorPos(32,22)
  1275.             mon.setBackgroundColor(colors.gray)
  1276.             mon.write(" 8 ")
  1277.             putLimit = putLimit.."8"
  1278.             sleep(0.2)
  1279.             mon.setCursorPos(32,22)
  1280.             mon.setBackgroundColor(colors.lightGray)
  1281.             mon.write(" 8 ")
  1282.             mon.setBackgroundColor(1,1)
  1283.             mon.setBackgroundColor(colors.black)
  1284.             mon.write(" ")
  1285.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 22 then
  1286.             mon.setCursorPos(36,22)
  1287.             mon.setBackgroundColor(colors.gray)
  1288.             mon.write(" 9 ")
  1289.             putLimit = putLimit.."9"
  1290.             sleep(0.2)
  1291.             mon.setCursorPos(36,22)
  1292.             mon.setBackgroundColor(colors.lightGray)
  1293.             mon.write(" 9 ")
  1294.             mon.setBackgroundColor(1,1)
  1295.             mon.setBackgroundColor(colors.black)
  1296.             mon.write(" ")
  1297.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 23 then
  1298.             mon.setCursorPos(28,23)
  1299.             mon.setBackgroundColor(colors.gray)
  1300.             mon.write(" < ")
  1301.             putLimit = string.sub(putLimit,0,string.len(putLimit)-1)
  1302.             sleep(0.2)
  1303.             mon.setCursorPos(28,23)
  1304.             mon.setBackgroundColor(colors.red)
  1305.             mon.write(" < ")
  1306.             mon.setBackgroundColor(1,1)
  1307.             mon.setBackgroundColor(colors.black)
  1308.             mon.write(" ")
  1309.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 23 then
  1310.             mon.setCursorPos(32,23)
  1311.             mon.setBackgroundColor(colors.gray)
  1312.             mon.write(" 0 ")
  1313.             putLimit = putLimit.."0"
  1314.             sleep(0.2)
  1315.             mon.setCursorPos(32,23)
  1316.             mon.setBackgroundColor(colors.lightGray)
  1317.             mon.write(" 0 ")
  1318.             mon.setBackgroundColor(1,1)
  1319.             mon.setBackgroundColor(colors.black)
  1320.             mon.write(" ")
  1321.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 23 then
  1322.             mon.setCursorPos(36,23)
  1323.             mon.setBackgroundColor(colors.gray)
  1324.             mon.write(" X ")
  1325.             putLimit = ""
  1326.             sleep(0.2)
  1327.             mon.setCursorPos(36,23)
  1328.             mon.setBackgroundColor(colors.red)
  1329.             mon.write(" X ")
  1330.             mon.setBackgroundColor(1,1)
  1331.             mon.setBackgroundColor(colors.black)
  1332.             mon.write(" ")
  1333.         elseif xCPos >= 42 and xCPos <= 47 and yCPos == 23 then
  1334.             putLimit = ""
  1335.             drawClear(27,48,17,24)
  1336.             currentControls = "main"
  1337.         elseif xCPos >= 42 and xCPos <= 47 and yCPos == 21 then
  1338.             if currentControls == "editInput" then
  1339.                 if putLimit == "" then
  1340.                     putLimitNum = 0
  1341.                 else
  1342.                     putLimitNum = tonumber(putLimit)
  1343.                 end
  1344.                 input.setSignalLowFlow(putLimitNum)
  1345.                 addLog("logs.cfg",getTime(false),"InputMax > "..convertRF(putLimitNum))
  1346.             else
  1347.                 if putLimit == "" then
  1348.                     putLimitNum = 0
  1349.                 else
  1350.                     putLimitNum = tonumber(putLimit)
  1351.                 end
  1352.                 output.setSignalLowFlow(putLimitNum)
  1353.                 addLog("logs.cfg",getTime(false),"OutputMax > "..convertRF(putLimitNum))
  1354.             end
  1355.             putLimit = ""
  1356.             drawClear(27,48,17,24)
  1357.             currentControls = "main"
  1358.         end
  1359.     elseif currentControls == "editConfig" then
  1360.         if xCPos >= 28 and xCPos <= 28+8 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1361.             drawButton(26+2,26+10,16+3,16+4,"Detect","Flux_Gate",colors.gray)
  1362.             detectInOutput()
  1363.             addLog("logs.cfg",getTime(false),"Detected Flux_Gates")
  1364.         elseif xCPos >= 26+16 and xCPos <= 26+16+6 and yCPos >= 16+7 and yCPos <= 16+7 then
  1365.             currentControls = "main"
  1366.         elseif xCPos >= 40 and xCPos <= 47 and yCPos >= 19 and yCPos <= 20 then
  1367.             currentControls = "editTimezone"
  1368.         end
  1369.     elseif currentControls == "editTimezone" then
  1370.         if xCPos >= 26+9 and xCPos <= 26+15 and yCPos >= 16+7 and yCPos <= 16+7 then
  1371.             currentControls = "main"
  1372.         elseif xCPos >= 26+16 and xCPos <= 26+16+6 and yCPos >= 16+7 and yCPos <= 16+7 then
  1373.             if timediff >= -12 and timediff <= 12 then
  1374.                 editConfigFile("config.cfg",1,"Timezone: "..timediff)
  1375.             elseif timediff < -12 then
  1376.                 editConfigFile("config.cfg",1,"Timezone: -12")
  1377.             elseif timediff > 12 then
  1378.                 editConfigFile("config.cfg",1,"Timezone: 12")
  1379.             end
  1380.             addLog("logs.cfg",getTime(false),"Edited Timezone")
  1381.             currentControls = "main"
  1382.         elseif xCPos >= 26+2+3 and xCPos <= 26+2+4+2 and yCPos >= 16+4 and yCPos <= 16+4 then
  1383.             timediff = timediff-1
  1384.         elseif xCPos >= 26+2+4+8 and xCPos <= 26+2+4+6+5 and yCPos >= 16+4 and yCPos <= 16+4 then
  1385.             timediff = timediff+1
  1386.         end
  1387.     end
  1388. end
  1389.  
  1390. while true do
  1391.     parallel.waitForAny(drawAll,clickListener)
  1392. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement