Guest User

startup

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