Florian86

CC_Modem_Draconic_Core_Levels

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