Advertisement
Guest User

Untitled

a guest
May 24th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 36.20 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.     energyTransfer = core.getTransferPerTick()
  676.     if limitTransfer == true then
  677.         inputRate = input.getFlow()
  678.         outputRate = output.getFlow()
  679.     end
  680.     mon.setCursorPos(xPos, yPos)
  681.     if energyMax < 50000000 then
  682.         tier = 1
  683.     elseif energyMax < 300000000 then
  684.         tier = 2
  685.     elseif energyMax < 2000000000 then
  686.         tier = 3
  687.     elseif energyMax < 10000000000 then
  688.         tier = 4
  689.     elseif energyMax < 50000000000 then
  690.         tier = 5
  691.     elseif energyMax < 400000000000 then
  692.         tier = 6
  693.     elseif energyMax < 3000000000000 then
  694.         tier = 7
  695.     else
  696.         tier = 8
  697.     end
  698.     mon.write("Tier: ")
  699.     mon.write(tier)
  700.     mon.setCursorPos(xPos+7, yPos)
  701.     mon.write("  ")
  702.     mon.setCursorPos(xPos, yPos+1)
  703.     mon.write("Stored: ")
  704.     if energyStored < 1000 then
  705.         mon.write(energyStored)
  706.     elseif energyStored < 1000000 then
  707.         mon.write(round((energyStored/1000),1))
  708.         mon.write("k")
  709.     elseif energyStored < 1000000000 then
  710.         mon.write(round((energyStored/1000000),1))
  711.         mon.write("M")
  712.     elseif energyStored < 1000000000000 then
  713.         mon.write(round((energyStored/1000000000),1))
  714.         mon.write("G")
  715.     elseif energyStored < 1000000000000000 then
  716.         mon.write(round((energyStored/1000000000000),1))
  717.         mon.write("T")
  718.     elseif energyStored < 1000000000000000000 then
  719.         mon.write(round((energyStored/1000000000000000),1))
  720.         mon.write("P")
  721.     elseif energyStored < 1000000000000000000000 then
  722.         mon.write(round((energyStored/1000000000000000000),1))
  723.         mon.write("E")
  724.     end
  725.     mon.write("RF")
  726.     mon.write("/")
  727.     if energyMax < 1000 then
  728.         mon.write(energyMax)
  729.     elseif energyMax < 1000000 then
  730.         mon.write(round((energyMax/1000),1))
  731.         mon.write("k")
  732.     elseif energyMax < 1000000000 then
  733.         mon.write(round((energyMax/1000000),1))
  734.         mon.write("M")
  735.     elseif energyMax < 1000000000000 then
  736.         mon.write(round((energyMax/1000000000),1))
  737.         mon.write("G")
  738.     elseif energyMax < 1000000000000000 then
  739.         mon.write(round((energyMax/1000000000000),1))
  740.         mon.write("T")
  741.     elseif energyMax < 1000000000000000000 then
  742.         mon.write(round((energyMax/1000000000000000 ),1))
  743.         mon.write("P")
  744.     elseif energyMax < 1000000000000000000000 then
  745.         mon.write(round((energyMax/1000000000000000000),1))
  746.         mon.write("E")
  747.     end
  748.     mon.write("RF")
  749.     mon.setCursorPos(xPos, yPos+2)
  750.     mon.setBackgroundColor(colors.lightGray)
  751.     for l = 1, 20, 1 do
  752.         mon.write(" ")
  753.     end
  754.     mon.setCursorPos(xPos, yPos+2)
  755.     mon.setBackgroundColor(colors.lime)
  756.     for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do
  757.         mon.write(" ")
  758.     end
  759.     mon.setCursorPos(xPos, yPos+3)
  760.     mon.setBackgroundColor(colors.lightGray)
  761.     for l = 1, 20, 1 do
  762.         mon.write(" ")
  763.     end
  764.     mon.setCursorPos(xPos, yPos+3)
  765.     mon.setBackgroundColor(colors.lime)
  766.     for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do
  767.         mon.write(" ")
  768.     end
  769.     mon.setBackgroundColor(colors.black)
  770.     mon.setCursorPos(xPos, yPos+4)
  771.     mon.write("                      ")
  772.     if string.len(tostring(round((energyStored/energyMax)*100))) == 1 then
  773.         if round((energyStored/energyMax)*100) <= 10 then
  774.             mon.setCursorPos(xPos, yPos+4)
  775.             mon.write(round((energyStored/energyMax)*100))
  776.             mon.setCursorPos(xPos+1, yPos+4)
  777.             mon.write("% ")
  778.         else
  779.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5), yPos+4)
  780.             mon.write(round((energyStored/energyMax)*100))
  781.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5)+1, yPos+4)
  782.             mon.write("% ")
  783.         end
  784.     elseif string.len(tostring(round((energyStored/energyMax)*100))) == 2 then
  785.         if round((energyStored/energyMax)*100) <= 15 then
  786.             mon.setCursorPos(xPos, yPos+4)
  787.             mon.write(round((energyStored/energyMax)*100))
  788.             mon.setCursorPos(xPos+2, yPos+4)
  789.             mon.write("% ")
  790.         else
  791.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5), yPos+4)
  792.             mon.write(round((energyStored/energyMax)*100))
  793.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5)+2, yPos+4)
  794.             mon.write("% ")
  795.         end
  796.     elseif string.len(tostring(round((energyStored/energyMax)*100))) == 3 then
  797.         if round((energyStored/energyMax)*100) <= 20 then
  798.             mon.setCursorPos(xPos, yPos+4)
  799.             mon.write(round((energyStored/energyMax)*100))
  800.             mon.setCursorPos(xPos+3, yPos+4)
  801.             mon.write("% ")
  802.         else
  803.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5), yPos+4)
  804.             mon.write(round((energyStored/energyMax)*100))
  805.             mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5)+3, yPos+4)
  806.             mon.write("% ")
  807.         end
  808.     end
  809.     mon.setCursorPos(xPos, yPos+5)
  810.     mon.write("InputMax:")
  811.     mon.setCursorPos(xPos, yPos+6)
  812.     mon.write("         ")
  813.     mon.setCursorPos(xPos, yPos+6)
  814.     mon.setTextColor(colors.lime)
  815.     if limitTransfer == true then
  816.         if inputRate == 0 then
  817.             mon.setTextColor(colors.red)
  818.         end
  819.         if inputRate < 1000 then
  820.             mon.write(inputRate)
  821.         elseif inputRate < 1000000 then
  822.             mon.write(round((inputRate/1000),1))
  823.             mon.write("k")
  824.         elseif inputRate < 1000000000 then
  825.             mon.write(round((inputRate/1000000),1))
  826.             mon.write("M")
  827.         elseif inputRate < 1000000000000 then
  828.             mon.write(round((inputRate/1000000000),1))
  829.             mon.write("G")
  830.         elseif inputRate < 1000000000000000 then
  831.             mon.write(round((inputRate/1000000000000),1))
  832.             mon.write("T")
  833.         elseif inputRate < 1000000000000000000 then
  834.             mon.write(round((inputRate/1000000000000000 ),1))
  835.             mon.write("P")
  836.         elseif inputRate < 1000000000000000000000 then
  837.             mon.write(round((inputRate/1000000000000000000),1))
  838.             mon.write("E")
  839.         end
  840.         mon.write("RF")
  841.     else
  842.         mon.write("INFINITE")
  843.     end
  844.     mon.setTextColor(colors.white)
  845.     mon.setCursorPos(xPos+12, yPos+5)
  846.     mon.write("OutputMax:")
  847.     mon.setCursorPos(xPos+12, yPos+6)
  848.     mon.write("         ")
  849.     mon.setTextColor(colors.red)
  850.     mon.setCursorPos(xPos+12, yPos+6)
  851.     if limitTransfer == true then
  852.         if outputRate < 1000 then
  853.             mon.write(outputRate)
  854.         elseif outputRate < 1000000 then
  855.             mon.write(round((outputRate/1000),1))
  856.             mon.write("k")
  857.         elseif outputRate < 1000000000 then
  858.             mon.write(round((outputRate/1000000),1))
  859.             mon.write("M")
  860.         elseif outputRate < 1000000000000 then
  861.             mon.write(round((outputRate/1000000000),1))
  862.             mon.write("G")
  863.         elseif outputRate < 1000000000000000 then
  864.             mon.write(round((outputRate/1000000000000),1))
  865.             mon.write("T")
  866.         elseif outputRate < 1000000000000000000 then
  867.             mon.write(round((outputRate/1000000000000000),1))
  868.             mon.write("P")
  869.         elseif outputRate < 1000000000000000000000 then
  870.             mon.write(round((outputRate/1000000000000000000),1))
  871.             mon.write("E")
  872.         end
  873.         mon.write("RF")
  874.     else
  875.         mon.write("INFINITE")
  876.     end
  877.     mon.setTextColor(colors.white)
  878.     mon.setCursorPos(xPos, yPos+7)
  879.     mon.write("Transfer:")
  880.     mon.setCursorPos(xPos, yPos+8)
  881.     if energyTransfer < 0 then
  882.         mon.setTextColor(colors.red)
  883.         if energyTransfer*(-1) < 1000 then
  884.             mon.write(energyTransfer)
  885.         elseif energyTransfer*(-1) < 1000000 then
  886.             mon.write(round((energyTransfer/1000),1))
  887.             mon.write("k")
  888.         elseif energyTransfer*(-1) < 1000000000 then
  889.             mon.write(round((energyTransfer/1000000),1))
  890.             mon.write("M")
  891.         elseif energyTransfer*(-1) < 1000000000000 then
  892.             mon.write(round((energyTransfer/1000000000),1))
  893.             mon.write("G")
  894.         elseif energyTransfer*(-1) < 1000000000000000 then
  895.             mon.write(round((energyTransfer/1000000000000),1))
  896.             mon.write("T")
  897.         elseif energyTransfer*(-1) < 1000000000000000000 then
  898.             mon.write(round((energyTransfer/1000000000000000),1))
  899.             mon.write("P")
  900.         elseif energyTransfer*(-1) < 1000000000000000000000 then
  901.             mon.write(round((energyTransfer/1000000000000000000),1))
  902.             mon.write("E")
  903.         end
  904.     elseif energyTransfer == 0 then
  905.         mon.setTextColor(colors.red)
  906.         mon.write("0")
  907.     else
  908.         mon.setTextColor(colors.lime)
  909.         if energyTransfer < 1000 then
  910.             mon.write(energyTransfer)
  911.         elseif energyTransfer < 1000000 then
  912.             mon.write(round((energyTransfer/1000),1))
  913.             mon.write("k")
  914.         elseif energyTransfer < 1000000000 then
  915.             mon.write(round((energyTransfer/1000000),1))
  916.             mon.write("M")
  917.         elseif energyTransfer < 1000000000000 then
  918.             mon.write(round((energyTransfer/1000000000),1))
  919.             mon.write("G")
  920.         elseif energyTransfer < 1000000000000000 then
  921.             mon.write(round((energyTransfer/1000000000000),1))
  922.             mon.write("T")
  923.         elseif energyTransfer < 1000000000000000000 then
  924.             mon.write(round((energyTransfer/1000000000000000),1))
  925.             mon.write("P")
  926.         elseif energyTransfer < 1000000000000000000000 then
  927.             mon.write(round((energyTransfer/1000000000000000000),1))
  928.             mon.write("E")
  929.         end
  930.     end
  931.     mon.write("RF")
  932.     mon.setTextColor(colors.white)
  933.     mon.setCursorPos(xPos+12, yPos+7)
  934.     mon.write("Limited:")
  935.     mon.setCursorPos(xPos+12, yPos+8)
  936.     if limitTransfer == true then
  937.         mon.setTextColor(colors.lime)
  938.         mon.write("On")
  939.     else
  940.         mon.setTextColor(colors.red)
  941.         mon.write("Off")
  942.     end
  943.     mon.setTextColor(colors.white)
  944. end
  945.  
  946. local function drawAll()   
  947.     while true do
  948.         mon.clear()
  949.         versionText = "Version "..version.." by Game4Freak"
  950.         verPos = 51 - string.len(versionText)
  951.         mon.setCursorPos(verPos,26)
  952.         mon.setTextColor(colors.gray)
  953.         mon.write(versionText)
  954.         mon.setTextColor(colors.white)
  955.         drawBox(2,20,2,14,"ENERGY CORE")
  956.         drawBox(22,49,2,14,"DETAILS")
  957.         drawBox(2,24,16,25,"LOGS")
  958.         drawBox(26,49,16,25,"CONTROLS")
  959.         yPos = 4
  960.         xMin = 5
  961.         for xPos = xMin, xMin+12, 1 do
  962.             drawDetails(24,4)
  963.             drawControls(26,16)
  964.             getLogs("logs.cfg",2,16)
  965.             if tier <= 7 then
  966.                 colorShield = colors.lightBlue
  967.                 colorCore = colors.cyan
  968.             else
  969.                 colorShield = colors.yellow
  970.                 colorCore = colors.orange
  971.             end
  972.             xPos1 = xPos
  973.             if xPos1 >= xMin+13 then
  974.                 xPos1a = xPos1 - 13
  975.                 drawL1(xPos1a, yPos)
  976.             else
  977.                 drawL1(xPos1, yPos)
  978.             end
  979.             xPos2 = xPos + 1
  980.             if xPos2 >= xMin+13 then
  981.                 xPos2a = xPos2 - 13
  982.                 drawL2(xPos2a, yPos)
  983.             else
  984.                 drawL2(xPos2, yPos)
  985.             end
  986.             xPos3 = xPos + 2
  987.             if xPos3 >= xMin+13 then
  988.                 xPos3a = xPos3 - 13
  989.                 drawL3(xPos3a, yPos)
  990.             else
  991.                 drawL3(xPos3, yPos)
  992.             end
  993.             xPos4 = xPos + 3
  994.             if xPos4 >= xMin+13 then
  995.                 xPos4a = xPos4 - 13
  996.                 drawL4(xPos4a, yPos)
  997.             else
  998.                 drawL4(xPos4, yPos)
  999.             end
  1000.             xPos5 = xPos + 4
  1001.             if xPos5 >= xMin+13 then
  1002.                 xPos5a = xPos5 - 13
  1003.                 drawL5(xPos5a, yPos)
  1004.             else
  1005.                 drawL5(xPos5, yPos)
  1006.             end
  1007.             xPos6 = xPos + 5
  1008.             if xPos6 >= xMin+13 then
  1009.                 xPos6a = xPos6 - 13
  1010.                 drawL6(xPos6a, yPos)
  1011.             else
  1012.                 drawL6(xPos6, yPos)
  1013.             end
  1014.             xPos7 = xPos + 6
  1015.             if xPos7 >= xMin+13 then
  1016.                 xPos7a = xPos7 - 13
  1017.                 drawL7(xPos7a, yPos)
  1018.             else
  1019.                 drawL7(xPos7, yPos)
  1020.             end
  1021.             xPos8 = xPos + 7
  1022.             if xPos8 >= xMin+13 then
  1023.                 xPos8a = xPos8 - 13
  1024.                 drawL8(xPos8a, yPos)
  1025.             else
  1026.                 drawL8(xPos8, yPos)
  1027.             end
  1028.             xPos9 = xPos + 8
  1029.             if xPos9 >= xMin+13 then
  1030.                 xPos9a = xPos9 - 13
  1031.                 drawL9(xPos9a, yPos)
  1032.             else
  1033.                 drawL9(xPos9, yPos)
  1034.             end
  1035.             xPos10 = xPos + 9
  1036.             if xPos10 >= xMin+13 then
  1037.                 xPos10a = xPos10 - 13
  1038.                 drawL10(xPos10a, yPos)
  1039.             else
  1040.                 drawL10(xPos10, yPos)
  1041.             end
  1042.             xPos11 = xPos + 10
  1043.             if xPos11 >= xMin+13 then
  1044.                 xPos11a = xPos11 - 13
  1045.                 drawL11(xPos11a, yPos)
  1046.             else
  1047.                 drawL11(xPos11, yPos)
  1048.             end
  1049.             xPos12 = xPos + 11
  1050.             if xPos12 >= xMin+13 then
  1051.                 xPos12a = xPos12 - 13
  1052.                 drawL12(xPos12a, yPos)
  1053.             else
  1054.                 drawL12(xPos12, yPos)
  1055.             end
  1056.             xPos13 = xPos + 12
  1057.             if xPos13 >= xMin+13 then
  1058.                 xPos13a = xPos13 - 13
  1059.                 drawL13(xPos13a, yPos)
  1060.             else
  1061.                 drawL13(xPos13, yPos)
  1062.             end
  1063.             mon.setBackgroundColor(colors.black)
  1064.             mon.setCursorPos(xMin, yPos)
  1065.             mon.write("   ")
  1066.             mon.setCursorPos(xMin+10, yPos)
  1067.             mon.write("   ")
  1068.             mon.setCursorPos(xMin, yPos+1)
  1069.             mon.write(" ")
  1070.             mon.setCursorPos(xMin+12, yPos+1)
  1071.             mon.write(" ")
  1072.             mon.setCursorPos(xMin, yPos+7)
  1073.             mon.write(" ")
  1074.             mon.setCursorPos(xMin+12, yPos+7)
  1075.             mon.write(" ")
  1076.             mon.setCursorPos(xMin, yPos+8)
  1077.             mon.write("   ")
  1078.             mon.setCursorPos(xMin+10, yPos+8)
  1079.             mon.write("   ")
  1080.             mon.setCursorPos(51 - 8,1)
  1081.             mon.write(getTime())
  1082.             sleep(1)
  1083.         end
  1084.     end
  1085. end
  1086.  
  1087. local function clickListener()
  1088.     event, side, xCPos, yCPos = os.pullEvent("monitor_touch")
  1089.     if xCPos == 1 and yCPos == 1 then
  1090.         mon.setCursorPos(1,1)
  1091.         mon.write("Click!")
  1092.         sleep(1)
  1093.         mon.write("      ")
  1094.     end
  1095.     if currentControls == "main" then
  1096.         if xCPos >= 28 and xCPos <= 35 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1097.             drawClear(27,48,17,24)
  1098.             currentControls = "editInput"
  1099.         elseif xCPos >= 39 and xCPos <= 47 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1100.             drawClear(27,48,17,24)
  1101.             currentControls = "editOutput"
  1102.         elseif xCPos >= 28 and xCPos <= 35 and yCPos >= 22 and yCPos <= 23 then
  1103.             drawClear(27,48,17,24)
  1104.             currentControls = "editConfig"
  1105.         end
  1106.     elseif currentControls == "editInput" or currentControls == "editOutput" then
  1107.         if xCPos >= 28 and xCPos <= 30 and yCPos == 20 then
  1108.             mon.setCursorPos(28,20)
  1109.             mon.setBackgroundColor(colors.gray)
  1110.             mon.write(" 1 ")
  1111.             putLimit = putLimit .. "1"
  1112.             sleep(0.2)
  1113.             mon.setCursorPos(28,20)
  1114.             mon.setBackgroundColor(colors.lightGray)
  1115.             mon.write(" 1 ")
  1116.             mon.setBackgroundColor(1,1)
  1117.             mon.setBackgroundColor(colors.black)
  1118.             mon.write(" ")
  1119.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 20 then
  1120.             mon.setCursorPos(32,20)
  1121.             mon.setBackgroundColor(colors.gray)
  1122.             mon.write(" 2 ")
  1123.             putLimit = putLimit .. "2"
  1124.             sleep(0.2)
  1125.             mon.setCursorPos(32,20)
  1126.             mon.setBackgroundColor(colors.lightGray)
  1127.             mon.write(" 2 ")
  1128.             mon.setBackgroundColor(1,1)
  1129.             mon.setBackgroundColor(colors.black)
  1130.             mon.write(" ")
  1131.             mon.write(" ")
  1132.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 20 then
  1133.             mon.setCursorPos(36,20)
  1134.             mon.setBackgroundColor(colors.gray)
  1135.             mon.write(" 3 ")
  1136.             putLimit = putLimit.."3"
  1137.             sleep(0.2)
  1138.             mon.setCursorPos(36,20)
  1139.             mon.setBackgroundColor(colors.lightGray)
  1140.             mon.write(" 3 ")
  1141.             mon.setBackgroundColor(1,1)
  1142.             mon.setBackgroundColor(colors.black)
  1143.             mon.write(" ")
  1144.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 21 then
  1145.             mon.setCursorPos(28,21)
  1146.             mon.setBackgroundColor(colors.gray)
  1147.             mon.write(" 4 ")
  1148.             putLimit = putLimit.."4"
  1149.             sleep(0.2)
  1150.             mon.setCursorPos(28,21)
  1151.             mon.setBackgroundColor(colors.lightGray)
  1152.             mon.write(" 4 ")
  1153.             mon.setBackgroundColor(1,1)
  1154.             mon.setBackgroundColor(colors.black)
  1155.             mon.write(" ")
  1156.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 21 then
  1157.             mon.setCursorPos(32,21)
  1158.             mon.setBackgroundColor(colors.gray)
  1159.             mon.write(" 5 ")
  1160.             putLimit = putLimit.."5"
  1161.             sleep(0.2)
  1162.             mon.setCursorPos(32,21)
  1163.             mon.setBackgroundColor(colors.lightGray)
  1164.             mon.write(" 5 ")
  1165.             mon.setBackgroundColor(1,1)
  1166.             mon.setBackgroundColor(colors.black)
  1167.             mon.write(" ")
  1168.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 21 then
  1169.             mon.setCursorPos(36,21)
  1170.             mon.setBackgroundColor(colors.gray)
  1171.             mon.write(" 6 ")
  1172.             putLimit = putLimit.."6"
  1173.             sleep(0.2)
  1174.             mon.setCursorPos(36,21)
  1175.             mon.setBackgroundColor(colors.lightGray)
  1176.             mon.write(" 6 ")
  1177.             mon.setBackgroundColor(1,1)
  1178.             mon.setBackgroundColor(colors.black)
  1179.             mon.write(" ")
  1180.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 22 then
  1181.             mon.setCursorPos(28,22)
  1182.             mon.setBackgroundColor(colors.gray)
  1183.             mon.write(" 7 ")
  1184.             putLimit = putLimit.."7"
  1185.             sleep(0.2)
  1186.             mon.setCursorPos(28,22)
  1187.             mon.setBackgroundColor(colors.lightGray)
  1188.             mon.write(" 7 ")
  1189.             mon.setBackgroundColor(1,1)
  1190.             mon.setBackgroundColor(colors.black)
  1191.             mon.write(" ")
  1192.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 22 then
  1193.             mon.setCursorPos(32,22)
  1194.             mon.setBackgroundColor(colors.gray)
  1195.             mon.write(" 8 ")
  1196.             putLimit = putLimit.."8"
  1197.             sleep(0.2)
  1198.             mon.setCursorPos(32,22)
  1199.             mon.setBackgroundColor(colors.lightGray)
  1200.             mon.write(" 8 ")
  1201.             mon.setBackgroundColor(1,1)
  1202.             mon.setBackgroundColor(colors.black)
  1203.             mon.write(" ")
  1204.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 22 then
  1205.             mon.setCursorPos(36,22)
  1206.             mon.setBackgroundColor(colors.gray)
  1207.             mon.write(" 9 ")
  1208.             putLimit = putLimit.."9"
  1209.             sleep(0.2)
  1210.             mon.setCursorPos(36,22)
  1211.             mon.setBackgroundColor(colors.lightGray)
  1212.             mon.write(" 9 ")
  1213.             mon.setBackgroundColor(1,1)
  1214.             mon.setBackgroundColor(colors.black)
  1215.             mon.write(" ")
  1216.         elseif xCPos >= 28 and xCPos <= 30 and yCPos == 23 then
  1217.             mon.setCursorPos(28,23)
  1218.             mon.setBackgroundColor(colors.gray)
  1219.             mon.write(" < ")
  1220.             putLimit = string.sub(putLimit,0,string.len(putLimit)-1)
  1221.             sleep(0.2)
  1222.             mon.setCursorPos(28,23)
  1223.             mon.setBackgroundColor(colors.red)
  1224.             mon.write(" < ")
  1225.             mon.setBackgroundColor(1,1)
  1226.             mon.setBackgroundColor(colors.black)
  1227.             mon.write(" ")
  1228.         elseif xCPos >= 32 and xCPos <= 34 and yCPos == 23 then
  1229.             mon.setCursorPos(32,23)
  1230.             mon.setBackgroundColor(colors.gray)
  1231.             mon.write(" 0 ")
  1232.             putLimit = putLimit.."0"
  1233.             sleep(0.2)
  1234.             mon.setCursorPos(32,23)
  1235.             mon.setBackgroundColor(colors.lightGray)
  1236.             mon.write(" 0 ")
  1237.             mon.setBackgroundColor(1,1)
  1238.             mon.setBackgroundColor(colors.black)
  1239.             mon.write(" ")
  1240.         elseif xCPos >= 36 and xCPos <= 38 and yCPos == 23 then
  1241.             mon.setCursorPos(36,23)
  1242.             mon.setBackgroundColor(colors.gray)
  1243.             mon.write(" X ")
  1244.             putLimit = ""
  1245.             sleep(0.2)
  1246.             mon.setCursorPos(36,23)
  1247.             mon.setBackgroundColor(colors.red)
  1248.             mon.write(" X ")
  1249.             mon.setBackgroundColor(1,1)
  1250.             mon.setBackgroundColor(colors.black)
  1251.             mon.write(" ")
  1252.         elseif xCPos >= 42 and xCPos <= 47 and yCPos == 23 then
  1253.             putLimit = ""
  1254.             drawClear(27,48,17,24)
  1255.             currentControls = "main"
  1256.         elseif xCPos >= 42 and xCPos <= 47 and yCPos == 21 then
  1257.             if currentControls == "editInput" then
  1258.                 if putLimit == "" then
  1259.                     putLimitNum = 0
  1260.                 else
  1261.                     putLimitNum = tonumber(putLimit)
  1262.                 end
  1263.                 input.setSignalLowFlow(putLimitNum)
  1264.                 addLog("logs.cfg",getTime(),"Changed InputMax")
  1265.             else
  1266.                 if putLimit == "" then
  1267.                     putLimitNum = 0
  1268.                 else
  1269.                     putLimitNum = tonumber(putLimit)
  1270.                 end
  1271.                 output.setSignalLowFlow(putLimitNum)
  1272.                 addLog("logs.cfg",getTime(),"Changed OutputMax")
  1273.             end
  1274.             putLimit = ""
  1275.             drawClear(27,48,17,24)
  1276.             currentControls = "main"
  1277.         end
  1278.     elseif currentControls == "editConfig" then
  1279.         if xCPos >= 28 and xCPos <= 28+8 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then
  1280.             drawButton(26+2,26+10,16+3,16+4,"Detect","Flux_Gate",colors.gray)
  1281.             detectInOutput()
  1282.             addLog("logs.cfg",getTime(),"Detected Flux_Gates")
  1283.         elseif xCPos >= 26+16 and xCPos <= 26+16+6 and yCPos >= 16+7 and yCPos <= 16+7 then
  1284.             currentControls = "main"
  1285.         end
  1286.     end
  1287. end
  1288.  
  1289. while true do
  1290.     parallel.waitForAny(drawAll,clickListener)
  1291. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement