Advertisement
Guest User

(Wireless) Draconic Evolution Energy Ball Monitor

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