Advertisement
Bukisoh

Draconic core monitoring

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