theo33500

Untitled

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