Game4Freak

Draconic Core Monitor 1.0

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