Guest User

NC Grid Control

a guest
Dec 27th, 2019
3,268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.28 KB | None | 0 0
  1. -- APIs
  2.  
  3. local component = require("component")
  4. local term = require("term")
  5. local event = require("event")
  6. local computer = require("computer")
  7. local unicode = require("unicode")
  8. local gpu = component.gpu
  9.  
  10. -- Tables, Variables and Miscellaneous
  11.  
  12. local clear = false
  13. local count = 0
  14. local unit = 1
  15. local option = 0
  16. local state = false
  17. local list = 1
  18. local autoSupplyStatus = true
  19. local sendFuelButton = nil
  20. local repeatSend = 0
  21. local side = nil
  22. local amountFuel = 0
  23.  
  24. function round(number, decimals)
  25.   local power = 10^decimals
  26.   return math.floor(number*power)/power
  27. end
  28.  
  29. function shrink(number)
  30.   if number >= 10^12 then
  31.     return string.format("%.2ft", number / 10^12)
  32.   elseif number >= 10^9 then
  33.     return string.format("%.2fb", number / 10^9)
  34.   elseif number >= 10^6 then
  35.     return string.format("%.2fm", number / 10^6)
  36.   elseif number >= 10^3 then
  37.     return string.format("%.2fk", number / 10^3)
  38.   else
  39.     return tostring(number)
  40.   end
  41. end
  42.  
  43. function errorSequence(text, color, start)
  44.   if start == true then
  45.     term.setCursor((28-#text)/2, 13)
  46.   else
  47.     term.setCursor((136-#text)/2, 36)
  48.   end
  49.   gpu.setForeground(color)
  50.   io.write(text)
  51.   os.sleep(0.01)
  52. end
  53.  
  54. function throwError(text, start)
  55.   gpu.setBackground(0x000000)
  56.   errorSequence(text, 0x150000, start)
  57.   errorSequence(text, 0x2b0000, start)
  58.   errorSequence(text, 0x400000, start)
  59.   errorSequence(text, 0x550000, start)
  60.   errorSequence(text, 0x6a0000, start)
  61.   errorSequence(text, 0x800000, start)
  62.   errorSequence(text, 0x950000, start)
  63.   errorSequence(text, 0xaa0000, start)
  64.   errorSequence(text, 0xbf0000, start)
  65.   errorSequence(text, 0xd40000, start)
  66.   errorSequence(text, 0xea0000, start)
  67.   errorSequence(text, 0xff0000, start)
  68.   os.sleep(0.5)
  69.   errorSequence(text, 0xea0000, start)
  70.   errorSequence(text, 0xd40000, start)
  71.   errorSequence(text, 0xbf0000, start)
  72.   errorSequence(text, 0xaa0000, start)
  73.   errorSequence(text, 0x950000, start)
  74.   errorSequence(text, 0x800000, start)
  75.   errorSequence(text, 0x6a0000, start)
  76.   errorSequence(text, 0x550000, start)
  77.   errorSequence(text, 0x400000, start)
  78.   errorSequence(text, 0x2b0000, start)
  79.   errorSequence(text, 0x150000, start)
  80.   errorSequence(text, 0x000000, start)
  81.   if start == true then
  82.     gpu.setForeground(0xFFFFFF)
  83.   end
  84. end
  85.  
  86. -- Check Buttons
  87.  
  88. function checkButtonA(_, _, x, y)
  89.   if x >= 3 and x <= 52 and y >= 25 and y <= 35 then
  90.     gpu.setBackground(0x00AB66)
  91.     gpu.fill(3, 25, 49, 10, " ")
  92.     drawOnText(0x00AB66)
  93.     if event.pull("drop") then
  94.       gpu.setBackground(0xDC143C)
  95.       gpu.fill(3, 25, 49, 10, " ")
  96.       drawOnText(0xDC143C)
  97.       fission.activate()
  98.       state = true
  99.     end
  100.   end
  101. end
  102.  
  103. function checkButtonB(_, _, x, y)
  104.   if x >= 54 and x <= 103 and y >= 25 and y <= 35 then
  105.     gpu.setBackground(0x00AB66)
  106.     gpu.fill(54, 25, 49, 10, " ")
  107.     drawOffText(0x00AB66)
  108.     if event.pull("drop") then
  109.       gpu.setBackground(0xDC143C)
  110.       gpu.fill(54, 25, 49, 10, " ")
  111.       drawOffText(0xDC143C)
  112.       fission.deactivate()
  113.       state = false
  114.     end
  115.   end
  116. end
  117.  
  118. function checkReboot(_, _, x, y)
  119.   if x >= 103 and x <= 109 and y == 37 then
  120.     gpu.setBackground(0xD3D3D3)
  121.     term.setCursor(103, 37)
  122.     io.write("Reboot")
  123.     if event.pull("drop") then
  124.       gpu.setBackground(0x373737)
  125.       term.setCursor(103, 37)
  126.       io.write("Reboot")
  127.       computer.shutdown(true)
  128.     end
  129.   end
  130. end
  131.  
  132. function checkSupplyFuel(_, _, x, y)
  133.   if x >= 47 and x <= 58 and y == 37 then
  134.     gpu.setBackground(0xD3D3D3)
  135.     term.setCursor(47, 37)
  136.     io.write("Supply Fuel")
  137.     if event.pull("drop") then
  138.       gpu.setBackground(0x373737)
  139.       term.setCursor(47, 37)
  140.       io.write("Supply Fuel")
  141.       if component.isAvailable("me_exportbus") and component.isAvailable("database") and component.isAvailable("nc_fission_reactor") then
  142.         if component.isAvailable("me_controller") or component.isAvailable("me_interface") then
  143.           clear = true
  144.           gpu.setBackground(0x000000)
  145.           screenSupplyFuel()
  146.         else
  147.           throwError("Component(s) unavailable")
  148.         end
  149.       else
  150.         throwError("Component(s) unavailable")
  151.       end
  152.     end
  153.   end
  154. end
  155.  
  156. function checkInductionMatrix(_, _, x, y)
  157.   if x >= 63 and x <= 79 and y == 37 then
  158.     gpu.setBackground(0xD3D3D3)
  159.     term.setCursor(63, 37)
  160.     io.write("Induction Matrix")
  161.     if event.pull("drop") then
  162.       gpu.setBackground(0x373737)
  163.       term.setCursor(63, 37)
  164.       io.write("Induction Matrix")
  165.       if component.isAvailable("induction_matrix") then
  166.         clear = true
  167.         gpu.setBackground(0x000000)
  168.         screenInductionMatrix()
  169.       else
  170.         throwError("Component(s) unavailable")
  171.       end
  172.     end
  173.   end
  174. end
  175.  
  176. function checkWriteShell(_, _, x, y)
  177.   if x >= 84 and x <= 98 and y == 37 then
  178.     gpu.setBackground(0xD3D3D3)
  179.     term.setCursor(84, 37)
  180.     io.write("Write to Shell")
  181.     if event.pull("drop") then
  182.       gpu.setBackground(0x373737)
  183.       term.setCursor(84, 37)
  184.       io.write("Write to Shell")
  185.       local shell = io.open(".shrc", "w")
  186.       shell:write("/home/fission.lua")
  187.       shell:close()
  188.     end
  189.   end
  190. end
  191.  
  192. function checkFissionReactor(_, _, x, y)
  193.   if x >= 27 and x <= 42 and y == 37 then
  194.     gpu.setBackground(0xD3D3D3)
  195.     term.setCursor(27, 37)
  196.     io.write("Fission Reactor")
  197.     if event.pull("drop") then
  198.       gpu.setBackground(0x373737)
  199.       term.setCursor(27, 37)
  200.       io.write("Fission Reactor")
  201.       if component.isAvailable("nc_fission_reactor") then
  202.         clear = true
  203.         gpu.setBackground(0x000000)
  204.         screenFission()
  205.       else
  206.         throwError("Component(s) unavailable")
  207.       end
  208.     end
  209.   end
  210. end
  211.  
  212. ---- Fission Screen
  213.  
  214. function drawFissionBar()
  215.   fission = component.nc_fission_reactor
  216.   while event.pull(0.1, "interrupted") == nil do
  217.     if clear == true then break end
  218.  
  219.     -- Variables
  220.  
  221.     local energyStored = fission.getEnergyStored()/(fission.getMaxEnergyStored()/100)
  222.     if fission.getEnergyStored() == 0 then
  223.       energyStored = 0
  224.     end
  225.     local maxEnergyStored = fission.getMaxEnergyStored()/(fission.getMaxEnergyStored()/100)
  226.     local remainingEnergyStored = maxEnergyStored - energyStored
  227.     local heatLevel = fission.getHeatLevel()/(fission.getMaxHeatLevel()/100)
  228.     if fission.getHeatLevel() == 0 then
  229.       heatLevel = 0
  230.     end
  231.     local maxHeatLevel = fission.getMaxHeatLevel()/(fission.getMaxHeatLevel()/100)
  232.     local remainingHeatLevel = maxHeatLevel - heatLevel
  233.  
  234.     -- Energy Bar
  235.  
  236.     gpu.setBackground(0x00FF00)
  237.     gpu.fill(3, 3, math.floor(energyStored+0.5), 10, " ")
  238.     gpu.setBackground(0xD3D3D3)
  239.     gpu.fill(3 + math.floor(energyStored+0.5), 3, math.floor(remainingEnergyStored+0.5), 10, " ")
  240.     gpu.setBackground(0x1F1F1F)
  241.     term.setCursor(104, 6)
  242.     io.write("\27[32m", "ENERGY STORED:", "\27[37m")
  243.     term.setCursor(104, 8)
  244.     io.write(round(energyStored, 3), "%")
  245.     term.setCursor(104, 10)
  246.     io.write(shrink(fission.getEnergyStored()), " out of ", shrink(fission.getMaxEnergyStored()))
  247.  
  248.     -- Heat Bar
  249.  
  250.     gpu.setBackground(0xFF0000)
  251.     gpu.fill(3, 14, math.floor(heatLevel+0.5), 10, " ")
  252.     gpu.setBackground(0xD3D3D3)
  253.     gpu.fill(3 + math.floor(heatLevel+0.5), 14, math.floor(remainingHeatLevel+0.5), 10, " ")
  254.     gpu.setBackground(0x1F1F1F)
  255.     term.setCursor(104, 16)
  256.     io.write("\27[31m", "HEAT LEVEL:", "\27[37m")
  257.     term.setCursor(104, 18)
  258.     io.write(round(heatLevel, 3), "%")
  259.     term.setCursor(104, 20)
  260.     io.write(shrink(fission.getHeatLevel()), " out of ", shrink(fission.getMaxHeatLevel()))
  261.  
  262.     -- Draw Info
  263.  
  264.     gpu.setBackground(0x1F1F1F)
  265.     term.setCursor(104, 25)
  266.     io.write("\27[33m", "SIZE: ", "\27[37m", fission.getLengthX(), " x ", fission.getLengthY(), " x ", fission.getLengthZ())
  267.     term.setCursor(125, 25)
  268.     io.write("\27[33m", "CELLS: ", "\27[37m", fission.getNumberOfCells())
  269.     if fission.isProcessing() == true then
  270.       term.setCursor(104, 27)
  271.       io.write("\27[36m", fission.getFissionFuelName(), " FUEL STATS:", "\27[37m")
  272.       term.setCursor(104, 28)
  273.       io.write("Power Generation: ", fission.getFissionFuelPower())
  274.       term.setCursor(104, 29)
  275.       io.write("Heat Generation: ", fission.getFissionFuelHeat())
  276.     elseif fission.isComplete() == true then
  277.       gpu.fill(104, 27, 30, 3, " ")
  278.     end
  279.     term.setCursor(104, 31)
  280.     io.write("\27[36m", "REACTOR STATS:", "\27[37m")
  281.     term.setCursor(104, 32)
  282.     io.write("Power Generation: ", fission.getReactorProcessPower())
  283.     term.setCursor(104, 33)
  284.     io.write("Heat Generation: ", fission.getReactorProcessHeat())
  285.     term.setCursor(104, 34)
  286.     io.write("Cooling Rate: ", fission.getReactorCoolingRate())
  287.  
  288.     -- Automation
  289.  
  290.     if heatLevel >= 50 then
  291.       fission.deactivate()
  292.     end
  293.     if heatLevel == 0 and state == true then
  294.       fission.activate()
  295.     end
  296.   end
  297. end
  298.  
  299. ---- Draw Functions
  300.  
  301. function drawBackgroundBox()
  302.   gpu.setBackground(0x373737)
  303.   gpu.fill(2, 2, 134, 34, " ")
  304.   gpu.setBackground(0x000000)
  305. end
  306.  
  307. function drawButton()
  308.   gpu.setBackground(0xDC143C)
  309.   gpu.fill(3, 25, 49, 10, " ")
  310.   gpu.fill(54, 25, 49, 10, " ")
  311.   gpu.setBackground(0x1F1F1F)
  312.   gpu.fill(104, 6, 30, 5, " ")
  313.   gpu.fill(104, 16, 30, 5, " ")
  314.   gpu.fill(104, 25, 30, 10, " ")
  315.   gpu.setBackground(0x000000)
  316. end
  317.  
  318. function drawOnText(color)
  319.   gpu.setBackground(color)
  320.   term.setCursor(18, 27)
  321.   io.write(" ██████  ███    ██")
  322.   term.setCursor(18, 28)
  323.   io.write("██    ██ ████   ██")
  324.   term.setCursor(18, 29)
  325.   io.write("██    ██ ██ ██  ██")
  326.   term.setCursor(18, 30)
  327.   io.write("██    ██ ██  ██ ██")
  328.   term.setCursor(18, 31)
  329.   io.write(" ██████  ██   ████")
  330. end
  331.  
  332. function drawOffText(color)
  333.   gpu.setBackground(color)
  334.   term.setCursor(66, 27)
  335.   io.write(" ██████  ███████ ███████")
  336.   term.setCursor(66, 28)
  337.   io.write("██    ██ ██      ██")
  338.   term.setCursor(66, 29)
  339.   io.write("██    ██ █████   █████  ")
  340.   term.setCursor(66, 30)
  341.   io.write("██    ██ ██      ██")
  342.   term.setCursor(66, 31)
  343.   io.write(" ██████  ██      ██")
  344. end
  345.  
  346. function drawInputBox()
  347.   gpu.setBackground(0x000000)
  348.   term.setCursor(16, 13)
  349.   io.write("▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄")
  350.   term.setCursor(16, 14)
  351.   io.write("▌Amount of fuel:   ▐")
  352.   term.setCursor(16, 15)
  353.   io.write("▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀")
  354. end
  355.  
  356. function drawCubeNet()
  357.   term.setCursor(18, 18)
  358.   io.write("   ▐▛▀▀▜▌")
  359.   term.setCursor(18, 19)
  360.   io.write("   ▐▌UP▐▌")
  361.   term.setCursor(18, 20)
  362.   io.write("▄▄▄▟▙▄▄▟▙▄▄▄▄▄▄▄")
  363.   term.setCursor(18, 21)
  364.   io.write("▌NH▐▌WT▐▌SH▐▌ET▐")
  365.   term.setCursor(18, 22)
  366.   io.write("▀▀▀▜▛▀▀▜▛▀▀▀▀▀▀▀")
  367.   term.setCursor(18, 23)
  368.   io.write("   ▐▌DN▐▌")
  369.   term.setCursor(18, 24)
  370.   io.write("   ▐▙▄▄▟▌")
  371. end
  372.  
  373. ---- Supply Fuel Screen
  374.  
  375. -- Input Box
  376.  
  377. function inputBox(_, _, x, y)
  378.   if typing ~= true then
  379.     if x >= 16 and x <= 36 and y >= 13 and y <= 15 then
  380.       local overwrite = io.open("amountFuel", "w")
  381.       overwrite:write("")
  382.       overwrite:close()
  383.       typing = true
  384.       term.setCursor(33, 14)
  385.       io.write("  ")
  386.       term.setCursor(33, 14)
  387.       repeat
  388.         local key = {term.pull("key_down")}
  389.         if key[3] ~= 8 then
  390.           local fuel = io.open("amountFuel", "a")
  391.           fuel:write(unicode.char(key[3]))
  392.           io.write(unicode.char(key[3]))
  393.           fuel:close()
  394.           count = count + 1
  395.           term.setCursor(34, 14)
  396.         end
  397.       until count == 2
  398.       count = 0
  399.       typing = false
  400.       term.setCursor(33, 14)
  401.       local setVariable = io.open("amountFuel", "r")
  402.       amountFuel = tonumber(setVariable:read())
  403.       setVariable:close()
  404.       if amountFuel == nil then
  405.         amountFuel = 0
  406.       end
  407.       if amountFuel >= 65 then
  408.         amountFuel = 64
  409.       end
  410.       io.write("  ")
  411.       term.setCursor(33, 14)
  412.       io.write(amountFuel)
  413.     end
  414.   end
  415. end
  416.  
  417. -- Cube Net
  418.  
  419. function directionPick(_, _, x, y)
  420.   if x >= 23 and x <= 24 and y == 23 then
  421.     side = 0
  422.   elseif x >= 23 and x <= 24 and y == 19 then
  423.     side = 1
  424.   elseif x >= 19 and x <= 20 and y == 21 then
  425.     side = 2
  426.   elseif x >= 27 and x <= 28 and y == 21 then
  427.     side = 3
  428.   elseif x >= 23 and x <= 24 and y == 21 then
  429.     side = 4
  430.   elseif x >= 31 and x <= 32 and y == 21 then
  431.     side = 5
  432.   end
  433.   if side == 0 then
  434.     drawCubeNet()
  435.     term.setCursor(23, 23)
  436.     io.write("\27[32m", "DN", "\27[37m")
  437.   elseif side == 1 then
  438.     drawCubeNet()
  439.     term.setCursor(23, 19)
  440.     io.write("\27[32m", "UP", "\27[37m")
  441.   elseif side == 2 then
  442.     drawCubeNet()
  443.     term.setCursor(19, 21)
  444.     io.write("\27[32m", "NH", "\27[37m")
  445.   elseif side == 3 then
  446.     drawCubeNet()
  447.     term.setCursor(27, 21)
  448.     io.write("\27[32m", "SH", "\27[37m")
  449.   elseif side == 4 then
  450.     drawCubeNet()
  451.     term.setCursor(23, 21)
  452.     io.write("\27[32m", "WT", "\27[37m")
  453.   elseif side == 5 then
  454.     drawCubeNet()
  455.     term.setCursor(31, 21)
  456.     io.write("\27[32m", "ET", "\27[37m")
  457.   end
  458. end
  459.  
  460. -- Combo Box
  461.  
  462. function summonComboBox(_, _, x, y)
  463.   if openBox ~= true then
  464.     if x >= 53 and x <= 83 and y >= 4 and y <= 9 then
  465.       drawComboBox()
  466.       openBox = true
  467.       while event.pull(0.1, "interrupted") == nil do
  468.         gpu.setForeground(0x000000)
  469.         gpu.setBackground(0xD3D3D3)
  470.         if list >= 10 then
  471.           term.setCursor(61, 9)
  472.           io.write("Page  ", list, " of 13")
  473.         else
  474.           term.setCursor(62, 9)
  475.           io.write("Page ", list, " of 13")
  476.         end
  477.         gpu.setBackground(0xFFFFFF)
  478.         if list == 1 then
  479.           term.setCursor(54, 12)
  480.           io.write("TBU Fuel")
  481.           term.setCursor(54, 17)
  482.           io.write("TBU Oxide Fuel")
  483.           term.setCursor(54, 22)
  484.           io.write("LEU-233 Fuel")
  485.           term.setCursor(54, 27)
  486.           io.write("LEU-233 Oxide Fuel")
  487.         elseif list == 2 then
  488.           term.setCursor(54, 12)
  489.           io.write("HEU-233 Fuel")
  490.           term.setCursor(54, 17)
  491.           io.write("HEU-233 Oxide Fuel")
  492.           term.setCursor(54, 22)
  493.           io.write("LEU-235 Fuel")
  494.           term.setCursor(54, 27)
  495.           io.write("LEU-235 Oxide Fuel")
  496.         elseif list == 3 then
  497.           term.setCursor(54, 12)
  498.           io.write("HEU-235 Fuel")
  499.           term.setCursor(54, 17)
  500.           io.write("HEU-235 Oxide Fuel")
  501.           term.setCursor(54, 22)
  502.           io.write("LEN-236 Fuel")
  503.           term.setCursor(54, 27)
  504.           io.write("LEN-236 Oxide Fuel")
  505.         elseif list == 4 then
  506.           term.setCursor(54, 12)
  507.           io.write("HEN-236 Fuel")
  508.           term.setCursor(54, 17)
  509.           io.write("HEN-236 Oxide Fuel")
  510.           term.setCursor(54, 22)
  511.           io.write("LEP-239 Fuel")
  512.           term.setCursor(54, 27)
  513.           io.write("LEP-239 Oxide Fuel")
  514.         elseif list == 5 then
  515.           term.setCursor(54, 12)
  516.           io.write("HEP-239 Fuel")
  517.           term.setCursor(54, 17)
  518.           io.write("HEP-239 Oxide Fuel")
  519.           term.setCursor(54, 22)
  520.           io.write("LEP-241 Fuel")
  521.           term.setCursor(54, 27)
  522.           io.write("LEP-241 Oxide Fuel")
  523.         elseif list == 6 then
  524.           term.setCursor(54, 12)
  525.           io.write("MOX-239 Fuel")
  526.           term.setCursor(54, 17)
  527.           io.write("MOX-241 Fuel")
  528.           term.setCursor(54, 22)
  529.           io.write("LEA-242 Fuel")
  530.           term.setCursor(54, 27)
  531.           io.write("LEA-242 Oxide Fuel")
  532.         elseif list == 7 then
  533.           term.setCursor(54, 12)
  534.           io.write("HEA-242 Fuel")
  535.           term.setCursor(54, 17)
  536.           io.write("HEA-242 Oxide Fuel")
  537.           term.setCursor(54, 22)
  538.           io.write("LECm-243 Fuel")
  539.           term.setCursor(54, 27)
  540.           io.write("LECm-243 Oxide Fuel")
  541.         elseif list == 8 then
  542.           term.setCursor(54, 12)
  543.           io.write("HECm-243 Fuel")
  544.           term.setCursor(54, 17)
  545.           io.write("HECm-243 Oxide Fuel")
  546.           term.setCursor(54, 22)
  547.           io.write("LECm-245 Fuel")
  548.           term.setCursor(54, 27)
  549.           io.write("LECm-245 Oxide Fuel")
  550.         elseif list == 9 then
  551.           term.setCursor(54, 12)
  552.           io.write("HECm-245 Fuel")
  553.           term.setCursor(54, 17)
  554.           io.write("HECm-245 Oxide Fuel")
  555.           term.setCursor(54, 22)
  556.           io.write("LECm-247 Fuel")
  557.           term.setCursor(54, 27)
  558.           io.write("LECm-247 Oxide Fuel")
  559.         elseif list == 10 then
  560.           term.setCursor(54, 12)
  561.           io.write("HECm-247 Fuel")
  562.           term.setCursor(54, 17)
  563.           io.write("HECm-247 Oxide Fuel")
  564.           term.setCursor(54, 22)
  565.           io.write("LEB-248 Fuel")
  566.           term.setCursor(54, 27)
  567.           io.write("LEB-248 Oxide Fuel")
  568.         elseif list == 11 then
  569.           term.setCursor(54, 12)
  570.           io.write("HEB-248 Fuel")
  571.           term.setCursor(54, 17)
  572.           io.write("HEB-248 Oxide Fuel")
  573.           term.setCursor(54, 22)
  574.           io.write("LECf-249 Fuel")
  575.           term.setCursor(54, 27)
  576.           io.write("LECf-249 Oxide Fuel")
  577.         elseif list == 12 then
  578.           term.setCursor(54, 12)
  579.           io.write("HECf-249 Fuel")
  580.           term.setCursor(54, 17)
  581.           io.write("HECf-249 Oxide Fuel")
  582.           term.setCursor(54, 22)
  583.           io.write("LECf-251 Fuel")
  584.           term.setCursor(54, 27)
  585.           io.write("LECf-251 Oxide Fuel")
  586.         elseif list == 13 then
  587.           term.setCursor(54, 12)
  588.           io.write("HECf-251 Fuel")
  589.           term.setCursor(54, 17)
  590.           io.write("HECf-251 Oxide Fuel")
  591.         end
  592.         local situation = {event.pullMultiple("touch", "scroll")}
  593.         if situation[1] == "touch" then
  594.  
  595.           -- First Box
  596.  
  597.           if list == 1 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  598.             drawComboBox(true)
  599.             drawShortComboBox()
  600.             openBox = false
  601.             selectedFuel = "TBU Fuel"
  602.             break
  603.           elseif list == 2 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  604.             drawComboBox(true)
  605.             drawShortComboBox()
  606.             openBox = false
  607.             selectedFuel = "HEU-233 Fuel"
  608.             break
  609.           elseif list == 3 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  610.             drawComboBox(true)
  611.             drawShortComboBox()
  612.             openBox = false
  613.             selectedFuel = "HEU-235 Fuel"
  614.             break
  615.           elseif list == 4 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  616.             drawComboBox(true)
  617.             drawShortComboBox()
  618.             openBox = false
  619.             selectedFuel = "HEN-236 Fuel"
  620.             break
  621.           elseif list == 5 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  622.             drawComboBox(true)
  623.             drawShortComboBox()
  624.             openBox = false
  625.             selectedFuel = "HEP-239 Fuel"
  626.             break
  627.           elseif list == 6 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  628.             drawComboBox(true)
  629.             drawShortComboBox()
  630.             openBox = false
  631.             selectedFuel = "MOX-239 Fuel"
  632.             break
  633.           elseif list == 7 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  634.             drawComboBox(true)
  635.             drawShortComboBox()
  636.             openBox = false
  637.             selectedFuel = "HEA-242 Fuel"
  638.             break
  639.           elseif list == 8 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  640.             drawComboBox(true)
  641.             drawShortComboBox()
  642.             openBox = false
  643.             selectedFuel = "HECm-243 Fuel"
  644.             break
  645.           elseif list == 9 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  646.             drawComboBox(true)
  647.             drawShortComboBox()
  648.             openBox = false
  649.             selectedFuel = "HECm-245 Fuel"
  650.             break
  651.           elseif list == 10 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  652.             drawComboBox(true)
  653.             drawShortComboBox()
  654.             openBox = false
  655.             selectedFuel = "HECm-247 Fuel"
  656.             break
  657.           elseif list == 11 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  658.             drawComboBox(true)
  659.             drawShortComboBox()
  660.             openBox = false
  661.             selectedFuel = "HEB-248 Fuel"
  662.             break
  663.           elseif list == 12 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  664.             drawComboBox(true)
  665.             drawShortComboBox()
  666.             openBox = false
  667.             selectedFuel = "HECf-249 Fuel"
  668.             break
  669.           elseif list == 13 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 10 and situation[4] <= 14 then
  670.             drawComboBox(true)
  671.             drawShortComboBox()
  672.             openBox = false
  673.             selectedFuel = "HECf-251 Fuel"
  674.             break
  675.  
  676.             -- Second Box
  677.  
  678.           elseif list == 1 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  679.             drawComboBox(true)
  680.             drawShortComboBox()
  681.             openBox = false
  682.             selectedFuel = "TBU Oxide Fuel"
  683.             break
  684.           elseif list == 2 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  685.             drawComboBox(true)
  686.             drawShortComboBox()
  687.             openBox = false
  688.             selectedFuel = "HEU-233 Oxide Fuel"
  689.             break
  690.           elseif list == 3 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  691.             drawComboBox(true)
  692.             drawShortComboBox()
  693.             openBox = false
  694.             selectedFuel = "HEU-235 Oxide Fuel"
  695.             break
  696.           elseif list == 4 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  697.             drawComboBox(true)
  698.             drawShortComboBox()
  699.             openBox = false
  700.             selectedFuel = "HEN-236 Oxide Fuel"
  701.             break
  702.           elseif list == 5 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  703.             drawComboBox(true)
  704.             drawShortComboBox()
  705.             openBox = false
  706.             selectedFuel = "HEP-239 Oxide Fuel"
  707.             break
  708.           elseif list == 6 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  709.             drawComboBox(true)
  710.             drawShortComboBox()
  711.             openBox = false
  712.             selectedFuel = "MOX-241 Fuel"
  713.             break
  714.           elseif list == 7 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  715.             drawComboBox(true)
  716.             drawShortComboBox()
  717.             openBox = false
  718.             selectedFuel = "HEA-242 Oxide Fuel"
  719.             break
  720.           elseif list == 8 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  721.             drawComboBox(true)
  722.             drawShortComboBox()
  723.             openBox = false
  724.             selectedFuel = "HECm-243 Oxide Fuel"
  725.             break
  726.           elseif list == 9 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  727.             drawComboBox(true)
  728.             drawShortComboBox()
  729.             openBox = false
  730.             selectedFuel = "HECm-245 Oxide Fuel"
  731.             break
  732.           elseif list == 10 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  733.             drawComboBox(true)
  734.             drawShortComboBox()
  735.             openBox = false
  736.             selectedFuel = "HECm-247 Oxide Fuel"
  737.             break
  738.           elseif list == 11 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  739.             drawComboBox(true)
  740.             drawShortComboBox()
  741.             openBox = false
  742.             selectedFuel = "HEB-248 Oxide Fuel"
  743.             break
  744.           elseif list == 12 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  745.             drawComboBox(true)
  746.             drawShortComboBox()
  747.             openBox = false
  748.             selectedFuel = "HECf-249 Oxide Fuel"
  749.             break
  750.           elseif list == 13 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 15 and situation[4] <= 19 then
  751.             drawComboBox(true)
  752.             drawShortComboBox()
  753.             openBox = false
  754.             selectedFuel = "HECf-251 Oxide Fuel"
  755.             break
  756.  
  757.             -- Third Box
  758.  
  759.           elseif list == 1 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  760.             drawComboBox(true)
  761.             drawShortComboBox()
  762.             openBox = false
  763.             selectedFuel = "LEU-233 Fuel"
  764.             break
  765.           elseif list == 2 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  766.             drawComboBox(true)
  767.             drawShortComboBox()
  768.             openBox = false
  769.             selectedFuel = "LEU-235 Fuel"
  770.             break
  771.           elseif list == 3 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  772.             drawComboBox(true)
  773.             drawShortComboBox()
  774.             openBox = false
  775.             selectedFuel = "LEN-236 Fuel"
  776.             break
  777.           elseif list == 4 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  778.             drawComboBox(true)
  779.             drawShortComboBox()
  780.             openBox = false
  781.             selectedFuel = "LEP-239 Fuel"
  782.             break
  783.           elseif list == 5 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  784.             drawComboBox(true)
  785.             drawShortComboBox()
  786.             openBox = false
  787.             selectedFuel = "LEP-241 Fuel"
  788.             break
  789.           elseif list == 6 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  790.             drawComboBox(true)
  791.             drawShortComboBox()
  792.             openBox = false
  793.             selectedFuel = "LEA-242 Fuel"
  794.             break
  795.           elseif list == 7 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  796.             drawComboBox(true)
  797.             drawShortComboBox()
  798.             openBox = false
  799.             selectedFuel = "LECm-243 Fuel"
  800.             break
  801.           elseif list == 8 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  802.             drawComboBox(true)
  803.             drawShortComboBox()
  804.             openBox = false
  805.             selectedFuel = "LECm-245 Fuel"
  806.             break
  807.           elseif list == 9 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  808.             drawComboBox(true)
  809.             drawShortComboBox()
  810.             openBox = false
  811.             selectedFuel = "LECm-247 Fuel"
  812.             break
  813.           elseif list == 10 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  814.             drawComboBox(true)
  815.             drawShortComboBox()
  816.             openBox = false
  817.             selectedFuel = "LEB-248 Fuel"
  818.             break
  819.           elseif list == 11 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  820.             drawComboBox(true)
  821.             drawShortComboBox()
  822.             openBox = false
  823.             selectedFuel = "LECf-249 Fuel"
  824.             break
  825.           elseif list == 12 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 20 and situation[4] <= 24 then
  826.             drawComboBox(true)
  827.             drawShortComboBox()
  828.             openBox = false
  829.             selectedFuel = "LECf-251 Fuel"
  830.             break
  831.  
  832.             -- Fourth Box
  833.  
  834.           elseif list == 1 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  835.             drawComboBox(true)
  836.             drawShortComboBox()
  837.             openBox = false
  838.             selectedFuel = "LEU-233 Oxide Fuel"
  839.             break
  840.           elseif list == 2 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  841.             drawComboBox(true)
  842.             drawShortComboBox()
  843.             openBox = false
  844.             selectedFuel = "LEU-235 Oxide Fuel"
  845.             break
  846.           elseif list == 3 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  847.             drawComboBox(true)
  848.             drawShortComboBox()
  849.             openBox = false
  850.             selectedFuel = "LEN-236 Oxide Fuel"
  851.             break
  852.           elseif list == 4 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  853.             drawComboBox(true)
  854.             drawShortComboBox()
  855.             openBox = false
  856.             selectedFuel = "LEP-239 Oxide Fuel"
  857.             break
  858.           elseif list == 5 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  859.             drawComboBox(true)
  860.             drawShortComboBox()
  861.             openBox = false
  862.             selectedFuel = "LEP-241 Oxide Fuel"
  863.             break
  864.           elseif list == 6 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  865.             drawComboBox(true)
  866.             drawShortComboBox()
  867.             openBox = false
  868.             selectedFuel = "LEA-242 Oxide Fuel"
  869.             break
  870.           elseif list == 7 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  871.             drawComboBox(true)
  872.             drawShortComboBox()
  873.             openBox = false
  874.             selectedFuel = "LECm-243 Oxide Fuel"
  875.             break
  876.           elseif list == 8 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  877.             drawComboBox(true)
  878.             drawShortComboBox()
  879.             openBox = false
  880.             selectedFuel = "LECm-245 Oxide Fuel"
  881.             break
  882.           elseif list == 9 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  883.             drawComboBox(true)
  884.             drawShortComboBox()
  885.             openBox = false
  886.             selectedFuel = "LECm-247 Oxide Fuel"
  887.             break
  888.           elseif list == 10 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  889.             drawComboBox(true)
  890.             drawShortComboBox()
  891.             openBox = false
  892.             selectedFuel = "LEB-248 Oxide Fuel"
  893.             break
  894.           elseif list == 11 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  895.             drawComboBox(true)
  896.             drawShortComboBox()
  897.             openBox = false
  898.             selectedFuel = "LECf-249 Oxide Fuel"
  899.             break
  900.           elseif list == 12 and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 25 and situation[4] <= 30 then
  901.             drawComboBox(true)
  902.             drawShortComboBox()
  903.             openBox = false
  904.             selectedFuel = "LECf-251 Oxide Fuel"
  905.             break
  906.           end
  907.         end
  908.         if situation[1] == "touch" then
  909.           if not (situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 9 and situation[4] <= 30) then
  910.             drawComboBox(true)
  911.             openBox = false
  912.             break
  913.           end
  914.         elseif situation[1] == "scroll" and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 9 and situation[4] <= 30 and situation[5] == -1 and list ~= 13 then
  915.           drawComboBox()
  916.           list = list + 1
  917.         elseif situation[1] == "scroll" and situation[3] >= 53 and situation[3] <= 83 and situation[4] >= 9 and situation[4] <= 30 and situation[5] == 1 and list ~= 1 then
  918.           drawComboBox()
  919.           list = list - 1
  920.         end
  921.       end
  922.       term.setCursor(54, 6)
  923.       gpu.setBackground(0xFFFFFF)
  924.       gpu.setForeground(0x000000)
  925.       io.write(selectedFuel)
  926.       gpu.setBackground(0x000000)
  927.       gpu.setForeground(0xFFFFFF)
  928.     end
  929.   end
  930. end
  931.  
  932. function drawComboBox(wipe)
  933.   if wipe == true then
  934.     gpu.setBackground(0x000000)
  935.     gpu.fill(53, 9, 30, 21, " ")
  936.   elseif wipe == nil then
  937.     gpu.setBackground(0xD3D3D3)
  938.     gpu.fill(53, 9, 30, 1, " ")
  939.     gpu.setBackground(0xFFFFFF)
  940.     gpu.fill(53, 10, 30, 20, " ")
  941.   end
  942. end
  943.  
  944. function drawShortComboBox()
  945.   gpu.setBackground(0xFFFFFF)
  946.   gpu.fill(53, 4, 30, 5, " ")
  947. end
  948.  
  949. -- Send Fuel Button
  950.  
  951. function drawSendFuel(color)
  952.   gpu.setBackground(color)
  953.   gpu.fill(100, 15, 20, 5, " ")
  954.   term.setCursor(105, 17)
  955.   io.write("Send Fuel")
  956.   gpu.setBackground(0x000000)
  957. end
  958.  
  959. function sendFuel(_, _, x, y)
  960.   if x >= 100 and x <= 120 and y >= 15 and y <= 20 then
  961.     db.clear(1)
  962.     if autoSupplyStatus == true and sendFuelButton == nil then
  963.       if selectedFuel == nil or side == nil then
  964.           throwError("Value(s) empty")
  965.       else
  966.         drawSendFuel(0x00AB66)
  967.         sendFuelButton = true
  968.         me.store({label = selectedFuel}, db.address, 1)
  969.         eb.setExportConfiguration(side, 1, db.address, 1)
  970.         while event.pull(0.1, "interrupted") == nil and sendFuelButton == true do
  971.           eb.exportIntoSlot(side)
  972.         end
  973.       end
  974.     elseif autoSupplyStatus == true and sendFuelButton == true then
  975.       drawSendFuel(0xDC143C)
  976.       sendFuelButton = nil
  977.     elseif autoSupplyStatus == nil then
  978.       drawSendFuel(0x00AB66)
  979.       if event.pull("drop") then
  980.         drawSendFuel(0xDC143C)
  981.         if selectedFuel == nil or amountFuel == 0 or amountFuel == nil or side == nil then
  982.           throwError("Value(s) empty")
  983.         else
  984.           me.store({label = selectedFuel}, db.address, 1, amountFuel)
  985.           eb.setExportConfiguration(side, 1, db.address, 1)
  986.           gpu.setBackground(0x373737)
  987.           gpu.fill(50, 30, 36, 5, " ")
  988.           gpu.setBackground(0xD3D3D3)
  989.           gpu.fill(51, 31, 25, 3, " ")
  990.           while event.pull(0.1, "interrupted") == nil and repeatSend ~= amountFuel do
  991.             if autoSupplyStatus == true then break end
  992.             repeatSend = repeatSend + 1
  993.             eb.exportIntoSlot(side)
  994.             gpu.setBackground(0x1F1F1F)
  995.             gpu.fill(77, 31, 8, 3, " ")
  996.             term.setCursor(77, 31)
  997.             io.write(round((repeatSend/amountFuel)*100, 0), "%")
  998.             term.setCursor(77, 33)
  999.             io.write(repeatSend, " of ", amountFuel)
  1000.             gpu.setBackground(0x00FF00)
  1001.             gpu.fill(51, 31, (repeatSend/amountFuel)*25, 3, " ")
  1002.             gpu.setBackground(0x000000)
  1003.           end
  1004.           repeatSend = 0
  1005.         end
  1006.       end
  1007.     end
  1008.   end
  1009. end
  1010.  
  1011. function toggleAutoSupply(_, _, x, y)
  1012.   if x >= 100 and x <= 120 and y == 21 and autoSupplyStatus == true then
  1013.     autoSupplyStatus = nil
  1014.     drawSendFuel(0xDC143C)
  1015.     sendFuelButton = nil
  1016.   elseif x >= 100 and x <= 120 and y == 21 and autoSupplyStatus == nil then
  1017.     autoSupplyStatus = true
  1018.     gpu.setBackground(0x000000)
  1019.     gpu.fill(50, 30, 36, 5, " ")
  1020.   end
  1021.   term.setCursor(100, 21)
  1022.   if autoSupplyStatus == true then
  1023.     io.write("Auto-Supply: ", "\27[32m", "Enabled ", "\27[37m")
  1024.   else
  1025.     io.write("Auto-Supply: ", "\27[31m", "Disabled", "\27[37m")
  1026.   end
  1027. end
  1028.  
  1029. ---- Induction Matrix Screen
  1030.  
  1031. function drawInductionBar()
  1032.   local im = component.induction_matrix
  1033.   while event.pull(0.1, "interrupted") == nil do
  1034.     if clear == true then break end
  1035.  
  1036.     -- Variables
  1037.  
  1038.     local inductionEnergyStored = unit*im.getEnergy()/(unit*im.getMaxEnergy()/100)
  1039.     if im.getEnergy() == 0 then
  1040.       inductionEnergyStored = 0
  1041.     end
  1042.     local inductionMaxEnergyStored = unit*im.getMaxEnergy()/(unit*im.getMaxEnergy()/100)
  1043.     local inductionRemainingEnergyStored = inductionMaxEnergyStored - inductionEnergyStored
  1044.  
  1045.     -- Energy Bar
  1046.  
  1047.     gpu.setBackground(0x00FF00)
  1048.     gpu.fill(18, 7, math.floor(inductionEnergyStored+0.5), 20, " ")
  1049.     gpu.setBackground(0xD3D3D3)
  1050.     gpu.fill(18 + math.floor(inductionEnergyStored+0.5), 7, math.floor(inductionRemainingEnergyStored+0.5), 20, " ")
  1051.     gpu.setBackground(0x1F1F1F)
  1052.     term.setCursor(18, 29)
  1053.     io.write("\27[32m", "ENERGY STORED:", "\27[37m")
  1054.     term.setCursor(33, 29)
  1055.     if unit == 1 then
  1056.       io.write("(EU)")
  1057.     elseif unit == 4 then
  1058.       io.write("(RF)")
  1059.     elseif unit == 10 then
  1060.       io.write("    ")
  1061.       term.setCursor(33, 29)
  1062.       io.write("(J)")
  1063.     end
  1064.     term.setCursor(18, 31)
  1065.     io.write(round(inductionEnergyStored, 3), "%")
  1066.     term.setCursor(18, 33)
  1067.     io.write(shrink(unit*im.getEnergy()), " out of ", shrink(unit*im.getMaxEnergy()))
  1068.  
  1069.     -- I/O
  1070.  
  1071.     term.setCursor(83, 29)
  1072.     io.write("\27[35m", "I/O STATISTICS:", "\27[37m")
  1073.     term.setCursor(99, 29)
  1074.     if unit == 1 then
  1075.       io.write("(EU/t)")
  1076.     elseif unit == 4 then
  1077.       io.write("(RF/t)")
  1078.     elseif unit == 10 then
  1079.       io.write("      ")
  1080.       term.setCursor(99, 29)
  1081.       io.write("(J/t)")
  1082.     end
  1083.     term.setCursor(83, 31)
  1084.     io.write("\27[36m", "INPUT: ", "\27[37m", shrink(unit*im.getInput()))
  1085.     term.setCursor(83, 33)
  1086.     io.write("\27[31m", "OUTPUT: ", "\27[37m", shrink(unit*im.getOutput()))
  1087.     if im.getInput() == 0 then
  1088.       gpu.fill(91, 31, 27, 1, " ")
  1089.     end
  1090.     if im.getOutput() == 0 then
  1091.       gpu.fill(92, 33, 26, 1, " ")
  1092.     end
  1093.   end
  1094. end
  1095.  
  1096. function drawInductionBackgroundBox()
  1097.   gpu.setBackground(0x373737)
  1098.   gpu.fill(17, 6, 102, 22, " ")
  1099.   gpu.setBackground(0x1F1F1F)
  1100.   gpu.fill(18, 29, 35, 5, " ")
  1101.   gpu.fill(83, 29, 35, 5, " ")
  1102.   gpu.fill(59, 29, 18, 5, " ")
  1103. end
  1104.  
  1105. function selectEnergyUnit(_, _, x, y)
  1106.   if x >= 59 and x <= 77 and y == 31 then
  1107.     unit = 1
  1108.     gpu.fill(18, 33, 35, 1, " ")
  1109.     gpu.fill(83, 31, 35, 3, " ")
  1110.   elseif x >= 59 and x <= 77 and y == 32 then
  1111.     unit = 4
  1112.     gpu.fill(18, 33, 35, 1, " ")
  1113.     gpu.fill(83, 31, 35, 3, " ")
  1114.   elseif x >= 59 and x <= 77 and y == 33 then
  1115.     unit = 10
  1116.     gpu.fill(18, 33, 35, 1, " ")
  1117.     gpu.fill(83, 31, 35, 3, " ")
  1118.   end
  1119.   if unit == 1 then
  1120.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1121.     io.write("\27[32m", "Energy Units  (EU)", "\27[37m")
  1122.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1123.     io.write("Redstone Flux (RF)")
  1124.     term.setCursor((136-#"Joule (J)")/2, 33)
  1125.     io.write("Joule (J)")
  1126.   elseif unit == 4 then
  1127.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1128.     io.write("Energy Units  (EU)")
  1129.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1130.     io.write("\27[32m", "Redstone Flux (RF)", "\27[37m")
  1131.     term.setCursor((136-#"Joule (J)")/2, 33)
  1132.     io.write("Joule (J)")
  1133.   elseif unit == 10 then
  1134.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1135.     io.write("Energy Units  (EU)")
  1136.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1137.     io.write("Redstone Flux (RF)")
  1138.     term.setCursor((136-#"Joule (J)")/2, 33)
  1139.     io.write("\27[32m", "Joule (J)", "\27[37m")
  1140.   end
  1141. end
  1142.  
  1143. ---- Menu
  1144.  
  1145. function drawMenu()
  1146.   gpu.setBackground(0x1F1F1F)
  1147.   gpu.fill(1, 37, 136, 1, " ")
  1148.   gpu.setBackground(0x373737)
  1149.   term.setCursor(27, 37)
  1150.   io.write("Fission Reactor")
  1151.   term.setCursor(47, 37)
  1152.   io.write("Supply Fuel")
  1153.   term.setCursor(63, 37)
  1154.   io.write("Induction Matrix")
  1155.   term.setCursor(84, 37)
  1156.   io.write("Write to Shell")
  1157.   term.setCursor(103, 37)
  1158.   io.write("Reboot")
  1159. end
  1160.  
  1161. function listenMenu()
  1162.   event.listen("touch", checkReboot)
  1163.   event.listen("touch", checkSupplyFuel)
  1164.   event.listen("touch", checkWriteShell)
  1165.   event.listen("touch", checkInductionMatrix)
  1166.   event.listen("touch", checkFissionReactor)
  1167. end
  1168.  
  1169. function ignoreTouch()
  1170.   event.ignore("touch", checkButtonA)
  1171.   event.ignore("touch", checkButtonB)
  1172.   event.ignore("touch", checkReboot)
  1173.   event.ignore("touch", checkSupplyFuel)
  1174.   event.ignore("touch", checkWriteShell)
  1175.   event.ignore("touch", checkInductionMatrix)
  1176.   event.ignore("touch", checkFissionReactor)
  1177.   event.ignore("touch", selectEnergyUnit)
  1178.   event.ignore("touch", inputBox)
  1179.   event.ignore("touch", summonComboBox)
  1180.   event.ignore("touch", sendFuel)
  1181.   event.ignore("touch", toggleAutoSupply)
  1182.   event.ignore("touch", directionPick)
  1183. end
  1184.  
  1185. ---- Screens
  1186.  
  1187. function screenFission()
  1188.   clear = false
  1189.   term.clear()
  1190.   ignoreTouch()
  1191.   drawBackgroundBox()
  1192.   drawButton()
  1193.   drawOnText(0xDC143C)
  1194.   drawOffText(0xDC143C)
  1195.   drawMenu()
  1196.   event.listen("touch", checkButtonA)
  1197.   event.listen("touch", checkButtonB)
  1198.   listenMenu()
  1199.   drawFissionBar()
  1200. end
  1201.  
  1202. function screenInductionMatrix()
  1203.   clear = false
  1204.   term.clear()
  1205.   ignoreTouch()
  1206.   drawMenu()
  1207.   listenMenu()
  1208.   event.listen("touch", selectEnergyUnit)
  1209.   drawInductionBackgroundBox()
  1210.   term.setCursor((136-#"UNITS:")/2, 29)
  1211.   io.write("\27[33m", "UNITS:", "\27[37m")
  1212.   if unit == 1 then
  1213.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1214.     io.write("\27[32m", "Energy Units  (EU)", "\27[37m")
  1215.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1216.     io.write("Redstone Flux (RF)")
  1217.     term.setCursor((136-#"Joule (J)")/2, 33)
  1218.     io.write("Joule (J)")
  1219.   elseif unit == 4 then
  1220.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1221.     io.write("Energy Units  (EU)")
  1222.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1223.     io.write("\27[32m", "Redstone Flux (RF)", "\27[37m")
  1224.     term.setCursor((136-#"Joule (J)")/2, 33)
  1225.     io.write("Joule (J)")
  1226.   elseif unit == 10 then
  1227.     term.setCursor((136-#"Energy Units  (EU)")/2, 31)
  1228.     io.write("Energy Units  (EU)")
  1229.     term.setCursor((136-#"Redstone Flux (RF)")/2, 32)
  1230.     io.write("Redstone Flux (RF)")
  1231.     term.setCursor((136-#"Joule (J)")/2, 33)
  1232.     io.write("\27[32m", "Joule (J)", "\27[37m")
  1233.   end
  1234.   drawInductionBar()
  1235. end
  1236.  
  1237. function screenSupplyFuel()
  1238.   clear = false
  1239.   term.clear()
  1240.   ignoreTouch()
  1241.   if component.isAvailable("me_interface") then
  1242.     me = component.me_interface
  1243.   elseif component.isAvailable("me_controller") then
  1244.     me = component.me_controller
  1245.   end
  1246.   eb = component.me_exportbus
  1247.   db = component.database
  1248.   drawMenu()
  1249.   listenMenu()
  1250.   drawInputBox()
  1251.   if side == nil then
  1252.     drawCubeNet()
  1253.   elseif side == 0 then
  1254.     drawCubeNet()
  1255.     term.setCursor(23, 23)
  1256.     io.write("\27[32m", "DN", "\27[37m")
  1257.   elseif side == 1 then
  1258.     drawCubeNet()
  1259.     term.setCursor(23, 19)
  1260.     io.write("\27[32m", "UP", "\27[37m")
  1261.   elseif side == 2 then
  1262.     drawCubeNet()
  1263.     term.setCursor(19, 21)
  1264.     io.write("\27[32m", "NH", "\27[37m")
  1265.   elseif side == 3 then
  1266.     drawCubeNet()
  1267.     term.setCursor(27, 21)
  1268.     io.write("\27[32m", "SH", "\27[37m")
  1269.   elseif side == 4 then
  1270.     drawCubeNet()
  1271.     term.setCursor(23, 21)
  1272.     io.write("\27[32m", "WT", "\27[37m")
  1273.   elseif side == 5 then
  1274.     drawCubeNet()
  1275.     term.setCursor(31, 21)
  1276.     io.write("\27[32m", "ET", "\27[37m")
  1277.   end
  1278.   event.listen("touch", inputBox)
  1279.   event.listen("touch", summonComboBox)
  1280.   event.listen("touch", sendFuel)
  1281.   event.listen("touch", toggleAutoSupply)
  1282.   event.listen("touch", directionPick)
  1283.   drawShortComboBox()
  1284.   drawSendFuel(0xDC143C)
  1285.   if selectedFuel ~= nil then
  1286.     term.setCursor(54, 6)
  1287.     gpu.setBackground(0xFFFFFF)
  1288.     gpu.setForeground(0x000000)
  1289.     io.write(selectedFuel)
  1290.     gpu.setBackground(0x000000)
  1291.     gpu.setForeground(0xFFFFFF)
  1292.   end
  1293.   term.setCursor(33, 14)
  1294.   io.write(amountFuel)
  1295.   term.setCursor(100, 21)
  1296.   if autoSupplyStatus == true then
  1297.     io.write("Auto-Supply: ", "\27[32m", "Enabled ", "\27[37m")
  1298.   else
  1299.     io.write("Auto-Supply: ", "\27[31m", "Disabled", "\27[37m")
  1300.   end
  1301.   while event.pull(0.1, "interrupted") == nil do if clear == true then break end end
  1302. end
  1303.  
  1304. ---- Start Program
  1305.  
  1306. function selectProgram()
  1307.   function drawSelection()
  1308.     gpu.setBackground(0x1F1F1F)
  1309.     term.setCursor((28-#"  Fission  Reactor  ")/2, 3)
  1310.     io.write("  Fission  Reactor  ")
  1311.     term.setCursor((28-#"  Supply  Fuel  ")/2, 5)
  1312.     io.write("  Supply  Fuel  ")
  1313.     term.setCursor((28-#"  Induction Matrix  ")/2, 7)
  1314.     io.write("  Induction Matrix  ")
  1315.     term.setCursor((28-#"  Write to Shell  ")/2, 9)
  1316.     io.write("  Write to Shell  ")
  1317.     term.setCursor((28-#"  Reboot  ")/2, 11)
  1318.     io.write("  Reboot  ")
  1319.   end
  1320.   drawSelection()
  1321.   while true do
  1322.     local cursor = {event.pull("key_down")}
  1323.     if cursor[4] == 0x1C and option ~= 0 then
  1324.       if option == 1 then
  1325.         if component.isAvailable("nc_fission_reactor") then
  1326.           term.clear()
  1327.           gpu.setResolution(136, 37)
  1328.           gpu.setBackground(0x000000)
  1329.           screenFission()
  1330.           break
  1331.         else
  1332.           throwError("Component(s) unavailable", true)
  1333.         end
  1334.       elseif option == 2 then
  1335.         if component.isAvailable("me_exportbus") and component.isAvailable("database") and component.isAvailable("nc_fission_reactor") then
  1336.           if component.isAvailable("me_controller") or component.isAvailable("me_interface") then
  1337.             term.clear()
  1338.             gpu.setResolution(136, 37)
  1339.             gpu.setBackground(0x000000)
  1340.             screenSupplyFuel()
  1341.             break
  1342.           else
  1343.             throwError("Component(s) unavailable", true)
  1344.           end
  1345.         else
  1346.           throwError("Component(s) unavailable", true)
  1347.         end
  1348.       elseif option == 3 then
  1349.         if component.isAvailable("induction_matrix") then
  1350.           term.clear()
  1351.           gpu.setResolution(136, 37)
  1352.           gpu.setBackground(0x000000)
  1353.           screenInductionMatrix()
  1354.           break
  1355.         else
  1356.           throwError("Component(s) unavailable", true)
  1357.         end
  1358.       elseif option == 4 then
  1359.         local shell = io.open(".shrc", "w")
  1360.         shell:write("/home/fission.lua")
  1361.         shell:close()
  1362.       elseif option == 5 then
  1363.         computer.shutdown(true)
  1364.       end
  1365.     end
  1366.     if cursor[4] == 0xD0 and option == 0 then
  1367.       drawSelection()
  1368.       term.setCursor((28-#"> Fission  Reactor <")/2, 3)
  1369.       io.write("> Fission  Reactor <")
  1370.       option = option + 1
  1371.     elseif cursor[4] == 0xD0 and option == 1 then
  1372.       drawSelection()
  1373.       term.setCursor((28-#"> Supply  Fuel <")/2, 5)
  1374.       io.write("> Supply  Fuel <")
  1375.       option = option + 1
  1376.     elseif cursor[4] == 0xD0 and option == 2 then
  1377.       drawSelection()
  1378.       term.setCursor((28-#"> Induction Matrix <")/2, 7)
  1379.       io.write("> Induction Matrix <")
  1380.       option = option + 1
  1381.     elseif cursor[4] == 0xD0 and option == 3 then
  1382.       drawSelection()
  1383.       term.setCursor((28-#"> Write to Shell <")/2, 9)
  1384.       io.write("> Write to Shell <")
  1385.       option = option + 1
  1386.     elseif cursor[4] == 0xD0 and option == 4 then
  1387.       drawSelection()
  1388.       term.setCursor((28-#"> Reboot <")/2, 11)
  1389.       io.write("> Reboot <")
  1390.       option = option + 1
  1391.     elseif cursor[4] == 0xC8 and option == 0 then
  1392.       drawSelection()
  1393.       term.setCursor((28-#"> Reboot <")/2, 11)
  1394.       io.write("> Reboot <")
  1395.       option = option + 5
  1396.     elseif cursor[4] == 0xC8 and option == 2 then
  1397.       drawSelection()
  1398.       term.setCursor((28-#"> Fission  Reactor <")/2, 3)
  1399.       io.write("> Fission  Reactor <")
  1400.       option = option - 1
  1401.     elseif cursor[4] == 0xC8 and option == 3 then
  1402.       drawSelection()
  1403.       term.setCursor((28-#"> Supply  Fuel <")/2, 5)
  1404.       io.write("> Supply  Fuel <")
  1405.       option = option - 1
  1406.     elseif cursor[4] == 0xC8 and option == 4 then
  1407.       drawSelection()
  1408.       term.setCursor((28-#"> Induction Matrix <")/2, 7)
  1409.       io.write("> Induction Matrix <")
  1410.       option = option - 1
  1411.     elseif cursor[4] == 0xC8 and option == 5 then
  1412.       drawSelection()
  1413.       term.setCursor((28-#"> Write to Shell <")/2, 9)
  1414.       io.write("> Write to Shell <")
  1415.       option = option - 1
  1416.     end
  1417.   end
  1418. end
  1419.  
  1420. term.clear()
  1421. gpu.setResolution(26, 13)
  1422. gpu.setBackground(0x373737)
  1423. gpu.fill(3, 2, 22, 11, " ")
  1424. gpu.setBackground(0x1F1F1F)
  1425. gpu.fill(4, 3, 20, 9, " ")
  1426. selectProgram()
Advertisement
Add Comment
Please, Sign In to add comment