Advertisement
Guest User

Untitled

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