Advertisement
DeathRealms

Draconic Core Monitor Edit

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