Advertisement
Guest User

Untitled

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