ROMVoid

reactor

Aug 22nd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.28 KB | None | 0 0
  1. version = "4.0.1"
  2.  
  3. -- Screen Numbers
  4. -- 0 - drawMainScreen()
  5. -- 1 - drawDisplayScreen()
  6. -- 2 - drawRodScreen()
  7. -- 3 - drawSettingScreen()
  8.  
  9. mouseWidth = 0
  10. mouseHeight = 0
  11. rodNumber = 0
  12. rodLevel = 0
  13.  
  14. rods = false
  15. setting = false
  16. control = false
  17.  
  18. maxFluidTank = 50000
  19. minLevelPower = 5000000
  20. maxLevelPower = 9000000
  21. minLevelSteam = maxFluidTank / 2
  22. maxLevelSteam = maxFluidTank
  23. currentPower = 0
  24.  
  25. reactors = {}
  26. reactorsManagement = {}
  27. monitors = {}
  28. monitorsCurrentReactor = {}
  29. monitorsCurrentScreen = {}
  30.  
  31. function draw_line(x, y, length, color, monitor)
  32.     tempMonitor = monitor
  33.     tempMonitor.setBackgroundColor(color)
  34.     tempMonitor.setCursorPos(x,y)
  35.     tempMonitor.write(string.rep(" ", length), tempMonitor)
  36. end
  37.  
  38. function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color, monitor)
  39.     tempMonitor = monitor
  40.     draw_line(x, y, length, bg_color, tempMonitor) --backgoround bar
  41.     local barSize = math.floor((minVal/maxVal) * length)
  42.     draw_line(x, y, barSize, bar_color, tempMonitor)     --progress so far
  43. end
  44.  
  45. function progress_bar_multi_line(x, y, length, minVal, maxVal, bar_color, bg_color, numberOFLine, monitor)
  46.     tempMonitor = monitor
  47.     local barSize = math.floor((minVal/maxVal) * length)
  48.     y = y - 1
  49.     for i=1,numberOFLine,1 do
  50.         draw_line(x, y + i, length, bg_color, tempMonitor) --background bar
  51.         draw_line(x, y + i, barSize, bar_color, tempMonitor)     --progress so far
  52.     end
  53. end
  54.  
  55. function draw_text(x, y, text, text_color, bg_color, monitor)
  56.     tempMonitor = monitor
  57.     monitor.setBackgroundColor(bg_color)
  58.     monitor.setTextColor(text_color)
  59.     monitor.setCursorPos(x,y)
  60.     monitor.write(text)
  61. end
  62.  
  63. function terminalOutput()
  64.     term.clear()
  65.     term.setBackgroundColor(colors.black)
  66.     term.setTextColor(colors.blue)
  67.     term.setCursorPos(1,1)
  68.     term.write("Reactor Monitor")
  69.    
  70.     term.setTextColor(colors.lime)
  71.     term.setCursorPos(1,2)
  72.     term.write("Version: " .. version)
  73.    
  74.     term.setTextColor(colors.red)
  75.     term.setCursorPos(1,4)
  76.     term.write("Important Infomation:")
  77.    
  78.     term.setTextColor(colors.white)
  79.     term.setCursorPos(1,5)
  80.     term.write("- Multi Reactor & Monitor support!")
  81.     term.setCursorPos(1,6)
  82.     term.write("- No Monitors support for compact control!")
  83.     term.setCursorPos(1,7)
  84.     term.write("- Auto detect for added & removed peripherals!")
  85.    
  86.     term.setTextColor(colors.cyan)
  87.     term.setCursorPos(1,9)
  88.     term.write("Peripherals Connected:")
  89. end
  90.  
  91. function initPeripherals()
  92.     local perList = peripheral.getNames()
  93.     local yLevel = 10
  94.     local reactorNumber = 1
  95.     local monitorNumber = 1
  96.     term.setTextColor(colors.yellow)
  97.    
  98.     monitors = {}
  99.     monitorsCurrentReactor = {}
  100.     monitorsCurrentScreen = {}
  101.     reactors = {}
  102.     reactorsManagement = {}
  103.  
  104.     for i=1,#perList,1 do
  105.         if peripheral.getType(perList[i]) == "monitor" then
  106.             table.insert(monitors, monitorNumber, perList[i])
  107.             table.insert(monitorsCurrentReactor, monitorNumber, 0)
  108.             table.insert(monitorsCurrentScreen, monitorNumber, "0")
  109.  
  110.             monitorNumber = monitorNumber +1
  111.         elseif peripheral.getType(perList[i]) == "BigReactors-Reactor" then
  112.             table.insert(reactors, reactorNumber, perList[i])
  113.             table.insert(reactorsManagement, reactorNumber, true)
  114.             reactorNumber = reactorNumber +1
  115.         end
  116.     end
  117.     term.setCursorPos(1,yLevel)
  118.     term.write((monitorNumber - 1) .. " Monitors Found!")
  119.    
  120.     term.setCursorPos(1,yLevel+ 1)
  121.     term.write((reactorNumber - 1) .. " Reactors Found!")
  122. end
  123.  
  124. function drawMainScreen(monitorName, reactorNumber)
  125.     local monitor = peripheral.wrap(monitorName)
  126.     local currentReactor = peripheral.wrap(reactors[reactorNumber + 1])
  127.  
  128.     displayW,displayH=monitor.getSize()
  129.     monitor.clear()
  130.     monitor.setBackgroundColor(colours.black)
  131.     monitor.setTextColour(colours.blue)
  132.     monitor.setCursorPos(5,1)
  133.     monitor.write("Reactor Monitor", monitor)
  134.  
  135.     monitor.setCursorPos((displayW / 2)-2,2)
  136.     monitor.write("v"..version, monitor)
  137.    
  138.     monitor.setTextColour(colours.blue)
  139.     monitor.setCursorPos(0,3)
  140.     monitor.write(string.rep("-", displayW), monitor)
  141.     monitor.setTextColour(colours.white)
  142.    
  143.     numberOfActiveReactros = 0
  144.     numberOfActivelyCooled = 0
  145.     totalBufferedEnergy = 0
  146.     totalBufferedSteam = 0
  147.     totalBufferedFuel = 0
  148.     totalBufferedWaste = 0
  149.     totalBufferedFuelWasteMax = 0
  150.    
  151.     for i=1,#reactors,1 do
  152.         tempReactor = peripheral.wrap(reactors[i])
  153.         if tempReactor.getActive() then
  154.             numberOfActiveReactros = numberOfActiveReactros + 1
  155.         end
  156.         if tempReactor.isActivelyCooled() then
  157.             numberOfActivelyCooled = numberOfActivelyCooled + 1
  158.             totalBufferedSteam = totalBufferedSteam + math.floor(tempReactor.getHotFluidAmount())
  159.         else          
  160.             totalBufferedEnergy = totalBufferedEnergy + math.floor(tempReactor.getEnergyStored())
  161.         end
  162.         totalBufferedFuel = totalBufferedFuel + math.floor(tempReactor.getFuelAmount())
  163.         totalBufferedWaste = totalBufferedWaste + math.floor(tempReactor.getWasteAmount())
  164.         totalBufferedFuelWasteMax = totalBufferedFuelWasteMax + math.floor(tempReactor.getFuelAmountMax())
  165.     end
  166.    
  167.     monitor.setCursorPos(1,4)
  168.     monitor.write("Number of Online Reactors: " .. numberOfActiveReactros .. "/" .. table.getn(reactors), monitor)
  169.     monitor.setCursorPos(1,5)
  170.     monitor.write("Number of Actively Cooled: " .. numberOfActivelyCooled .. "/" .. table.getn(reactors), monitor)
  171.    
  172.     monitor.setTextColour(colours.blue)
  173.     monitor.setCursorPos(0,6)
  174.     monitor.write(string.rep("-", displayW), monitor)
  175.     monitor.setTextColour(colours.white)
  176.    
  177.     monitor.setCursorPos(1,8)
  178.     monitor.setTextColour(colours.yellow)
  179.     monitor.write("Total Stored Energy: " .. totalBufferedEnergy .. " RF", monitor)
  180.     progress_bar_multi_line(2, 9, displayW-2, totalBufferedEnergy, (10000000 * (table.getn(reactors) - numberOfActivelyCooled)), colors.red, colors.gray, 2, monitor)
  181.     monitor.setBackgroundColor(colours.black)
  182.     monitor.setCursorPos(1,12)
  183.     monitor.write("Total Stored Steam: " .. totalBufferedSteam .. " mb", monitor)
  184.     progress_bar_multi_line(2, 13, displayW-2, totalBufferedSteam, ((50000 * (table.getn(reactors))) - numberOfActivelyCooled), colors.lightGray, colors.gray, 2, monitor)
  185.     monitor.setBackgroundColor(colours.black)
  186.     monitor.setCursorPos(1,16)
  187.     monitor.write("Total Stored Fuel: " .. totalBufferedFuel .. " mb", monitor)
  188.     progress_bar_multi_line(2, 17, displayW-2, totalBufferedFuel, totalBufferedFuelWasteMax, colors.yellow, colors.gray, 2, monitor)
  189.     monitor.setBackgroundColor(colours.black)
  190.     monitor.setCursorPos(1,20)
  191.     monitor.write("Total Stored Waste: " .. totalBufferedWaste .. " mb", monitor)
  192.     progress_bar_multi_line(2, 21, displayW-2, totalBufferedWaste, totalBufferedFuelWasteMax, colors.blue, colors.gray, 2, monitor)
  193.    
  194.     monitor.setTextColour(colours.white)
  195.     monitor.setBackgroundColor(colours.blue)
  196.     monitor.setCursorPos(1,displayH - 0)
  197.     monitor.write("                                        ", monitor)
  198.     monitor.setCursorPos(1,displayH - 1)
  199.     monitor.write("             Control Screen             ", monitor)
  200.     monitor.setCursorPos(1,displayH - 2)
  201.     monitor.write("                                        ", monitor)
  202.     monitor.setBackgroundColor(colours.black)
  203. end
  204.  
  205. function drawControlScreen(monitorName, reactorNumber, screenNumber)
  206.     local monitor = peripheral.wrap(monitorName)
  207.     local currentReactor = peripheral.wrap(reactors[reactorNumber + 1])
  208.    
  209.     displayW,displayH=monitor.getSize()
  210.     monitor.clear()
  211.     monitor.setBackgroundColor(colours.black)
  212.     numberOfControlRods = currentReactor.getNumberOfControlRods()
  213.     active = currentReactor.getActive()
  214.    
  215.     -----------Title---------------------
  216.     monitor.setTextColour(colours.blue)
  217.     monitor.setCursorPos(1,1)
  218.     monitor.write("Reactor Monitor", monitor)
  219.     monitor.setTextColour(colours.white)
  220.    
  221.     -----------Reactor Enable/Disable---------------------
  222.     monitor.setCursorPos(1,3)
  223.     monitor.write("Reactor: ", monitor)
  224.     if active then
  225.         monitor.setBackgroundColour(colours.blue)
  226.     else
  227.         monitor.setBackgroundColour(colours.grey)
  228.     end
  229.     monitor.setCursorPos(20,3)
  230.     monitor.write(" ON  ")
  231.    
  232.     if active then
  233.         monitor.setBackgroundColour(colours.grey)
  234.     else
  235.         monitor.setBackgroundColour(colours.blue)
  236.     end
  237.     monitor.setCursorPos(25,3)
  238.     monitor.write(" OFF ", monitor)
  239.     monitor.setBackgroundColour(colours.black)
  240.  
  241.     -------------Multi Reactor Support Controls-------------------
  242.     monitor.setBackgroundColour(colours.blue)
  243.     monitor.setCursorPos(displayW - 8,1)
  244.     monitor.write("<", monitor)
  245.     monitor.setCursorPos(displayW - 5,1)
  246.     monitor.write(">", monitor)
  247.     monitor.setCursorPos(displayW - 3,1)
  248.     monitor.setBackgroundColour(colours.black)
  249.     monitor.setTextColour(colours.yellow)
  250.     monitor.write("".. reactorNumber, monitor)
  251.  
  252.     -----------Section Lines---------------------
  253.     displayW,displayH=monitor.getSize()
  254.    
  255.     monitor.setTextColour(colours.blue)
  256.     monitor.setCursorPos(0,2)
  257.     monitor.write(string.rep("-", displayW), monitor)
  258.     monitor.setTextColour(colours.white)
  259.    
  260.     monitor.setTextColour(colours.blue)
  261.     monitor.setCursorPos(0,4)
  262.     monitor.write(string.rep("-", displayW, monitor))
  263.     monitor.setTextColour(colours.white)
  264.    
  265.     monitor.setTextColour(colours.blue)
  266.     monitor.setCursorPos(0,displayH - 2)
  267.     monitor.write(string.rep("-", displayW), monitor)
  268.     monitor.setTextColour(colours.white)
  269.    
  270.     monitor.setTextColour(colours.blue)
  271.     monitor.setCursorPos(0,displayH - 0)
  272.     monitor.write(string.rep("-", displayW), monitor)
  273.     monitor.setTextColour(colours.white)
  274.    
  275.     -----------Bottom Bar Buttons---------------------
  276.     if tonumber(monitorsCurrentScreen[screenNumber]) == 2 then
  277.         draw_text(displayW - 25,displayH - 1, " Control Rods ", colors.white, colours.grey, monitor)
  278.     else
  279.         draw_text(displayW - 25,displayH - 1, " Control Rods ", colors.white, colours.blue, monitor)
  280.     end
  281.  
  282.     if tonumber(monitorsCurrentScreen[screenNumber]) == 3 then
  283.         draw_text(displayW - 10,displayH - 1, " Settings ", colors.white, colours.grey, monitor)
  284.     else
  285.         draw_text(displayW - 10,displayH - 1, " Settings ", colors.white, colours.blue, monitor)
  286.     end
  287.  
  288.     monitor.setBackgroundColour(colours.green)
  289.     monitor.setCursorPos(2,displayH - 1)
  290.     monitor.write(" Main Menu ", monitor)
  291. end
  292.  
  293. function drawDisplayScreen(monitorName, reactorNumber)
  294.     local monitor = peripheral.wrap(monitorName)
  295.     local currentReactor = peripheral.wrap(reactors[reactorNumber + 1])
  296.  
  297.     monitor.setBackgroundColor(colours.black)
  298.     displayW,displayH=monitor.getSize()
  299.    
  300.     -----------Casing Heat---------------------
  301.     draw_text(2, 5, "Casing Heat: ", colors.yellow, colors.black, monitor)
  302.     local maxVal = 5000
  303.     local minVal = math.floor(currentReactor.getCasingTemperature())
  304.     draw_text(23, 5, minVal.." C", colors.white, colors.black, monitor)
  305.    
  306.     if minVal < 500 then
  307.     progress_bar(2, 6, displayW-2, minVal, maxVal, colors.lightBlue, colors.gray, monitor)
  308.     elseif minVal < 1000 then
  309.     progress_bar(2, 6, displayW-2, minVal, maxVal, colors.lime, colors.gray, monitor)
  310.     elseif minVal < 1500 then
  311.     progress_bar(2, 6, displayW-2, minVal, maxVal, colors.yellow, colors.gray, monitor)
  312.     elseif minVal >= 1500 then
  313.     progress_bar(2, 6, displayW-2, minVal, maxVal, colors.red, colors.gray, monitor)
  314.     end
  315.    
  316.     -----------Fuel Heat---------------------
  317.     draw_text(2, 8, "Fuel Heat: ", colors.yellow, colors.black, monitor)
  318.     local maxVal = 5000
  319.     local minVal = math.floor(currentReactor.getFuelTemperature())
  320.     draw_text(23, 8, minVal.." C", colors.white, colors.black, monitor)
  321.    
  322.     if minVal < 500 then
  323.     progress_bar(2, 9, displayW-2, minVal, maxVal, colors.lightBlue, colors.gray, monitor)
  324.     elseif minVal < 1000 then
  325.     progress_bar(2, 9, displayW-2, minVal, maxVal, colors.lime, colors.gray, monitor)
  326.     elseif minVal < 1500 then
  327.     progress_bar(2, 9, displayW-2, minVal, maxVal, colors.yellow, colors.gray, monitor)
  328.     elseif minVal >= 1500 then
  329.     progress_bar(2, 9, displayW-2, minVal, maxVal, colors.red, colors.gray, monitor)
  330.     end
  331.    
  332.     -----------Water Tank---------------------
  333.     if currentReactor.isActivelyCooled() then
  334.         draw_text(2, 11, "Water Tank: ", colors.yellow, colors.black, monitor)
  335.         local maxVal = currentReactor.getHotFluidAmountMax()
  336.         local minVal = math.floor(currentReactor.getCoolantAmount())
  337.         draw_text(23, 11, minVal.." mb", colors.white, colors.black, monitor)
  338.         progress_bar(2, 12, displayW-2, minVal, maxVal, colors.blue, colors.gray, monitor)
  339.     else
  340.     -----------Power Storage---------------------
  341.         draw_text(2, 11, "Power: ", colors.yellow, colors.black, monitor)
  342.         local maxVal = 10000000
  343.         local minVal = math.floor(currentReactor.getEnergyStored())
  344.         draw_text(23, 11, math.floor((minVal/maxVal)*100).."% " .."="..minVal.." RF", colors.white, colors.black, monitor)
  345.         progress_bar(2, 12, displayW-2, minVal, maxVal, colors.lightGray, colors.gray, monitor)
  346.     end
  347.    
  348.     yValue = 12
  349.    
  350.     -----------Steam Tank---------------------
  351.     if currentReactor.isActivelyCooled() then
  352.         draw_text(2, yValue +2, "Steam Tank: ", colors.yellow, colors.black, monitor)
  353.         local maxVal = currentReactor.getHotFluidAmountMax()
  354.         local minVal = math.floor(currentReactor.getHotFluidAmount())
  355.         draw_text(23, yValue +2, minVal.." mb", colors.white, colors.black, monitor)
  356.         progress_bar(2, yValue +3, displayW-2, minVal, maxVal, colors.lightGray, colors.gray, monitor)
  357.     end
  358.     if currentReactor.isActivelyCooled() then
  359.         yValue = yValue + 4
  360.     else
  361.         yValue = 13
  362.     end
  363.     -------------Fuel-------------------
  364.     draw_text(2, yValue+ 1, "Fuel: ", colors.yellow, colors.black, monitor)
  365.     fuel = math.floor(currentReactor.getFuelAmount())
  366.     draw_text(23, yValue + 1, fuel.." mb", colors.white, colors.black, monitor)
  367.    
  368.     -------------Waste-------------------
  369.     draw_text(2, yValue+ 3, "Waste: ", colors.yellow, colors.black, monitor)
  370.     waste = math.floor(currentReactor.getWasteAmount())
  371.     draw_text(23, yValue+ 3, waste.." mb", colors.white, colors.black, monitor)
  372.    
  373.     -------------ProducedLastTick-------------------
  374.     if currentReactor.isActivelyCooled() then
  375.         draw_text(2, yValue+ 5, "Hot Fluid/T: ", colors.yellow, colors.black, monitor)
  376.     else
  377.         draw_text(2, yValue+ 5, "RF/T: ", colors.yellow, colors.black, monitor)
  378.     end
  379.     waste = math.floor(currentReactor.getEnergyProducedLastTick())
  380.     if currentReactor.isActivelyCooled() then
  381.         draw_text(23, yValue+ 5, waste.." mb", colors.white, colors.black, monitor)
  382.     else
  383.         draw_text(23, yValue+ 5, waste.." RF", colors.white, colors.black, monitor)
  384.     end
  385.    
  386.     -------------Fuel Consumption-------------------
  387.     draw_text(2, yValue+ 7, "Fuel Consumption: ", colors.yellow, colors.black, monitor)
  388.     draw_text(23, yValue+ 7, currentReactor.getFuelConsumedLastTick().." mB/t", colors.white, colors.black, monitor)
  389.     monitor.setBackgroundColour(colours.black)
  390.    
  391.     if not currentReactor.isActivelyCooled() then
  392.         draw_text(2, yValue+ 9, "Power Usage(IO): ", colors.yellow, colors.black, monitor)
  393.         draw_text(23, yValue+ 9, math.abs((currentPower-currentReactor.getEnergyStored())).." RF/T)", colors.white, colors.black, monitor)
  394.         currentPower = currentReactor.getEnergyStored()
  395.     end
  396. end
  397.  
  398. function drawRodScreen(monitorName, reactorNumber)
  399.     local monitor = peripheral.wrap(monitorName)
  400.     local currentReactor = peripheral.wrap(reactors[reactorNumber + 1])
  401.  
  402.     monitor.setBackgroundColor(colours.black)
  403.     displayW,displayH=monitor.getSize()
  404.        
  405.     -------------Title-------------------
  406.     draw_text(15, 6, "Control Rods", colors.blue, colors.black, monitor)
  407.    
  408.     monitor.setTextColour(colours.blue)
  409.     monitor.setCursorPos(0,7)
  410.     monitor.write(string.rep("-", displayW), monitor)
  411.     monitor.setTextColour(colours.white)
  412.    
  413.     -------------Number of Control Rods-------------------
  414.     draw_text(1, 8, "Number of Control Rods: "..numberOfControlRods, colors.white, colors.black, monitor)
  415.  
  416.     monitor.setTextColour(colours.yellow)
  417.     monitor.setCursorPos(0,10)
  418.     monitor.write(string.rep("-", displayW), monitor)
  419.     monitor.setTextColour(colours.white)
  420.    
  421.     -------------Control Rod Number/Selection-------------------
  422.     draw_text(2, 11, "Rod "..rodNumber, colors.yellow, colors.black, monitor)
  423.     monitor.setBackgroundColour(colours.blue)
  424.     monitor.setCursorPos(9,11)
  425.     monitor.write(" + ", monitor)
  426.  
  427.     monitor.setCursorPos(13,11)
  428.     monitor.write(" - ", monitor)
  429.     monitor.setBackgroundColour(colours.black)
  430.    
  431.     monitor.setTextColour(colours.yellow)
  432.     monitor.setCursorPos(0,12)
  433.     monitor.write(string.rep("-", displayW), monitor)
  434.     monitor.setTextColour(colours.white)
  435.     -------------Control Rod Level/Increase and Decrease-------------------
  436.     local maxVal = 100
  437.     local minVal = math.floor(currentReactor.getControlRodLevel(rodNumber))
  438.     rodLevel = minVal
  439.     draw_text(2, 13, minVal.." %", colors.white, colors.black, monitor)
  440.     progress_bar(2, 14, displayW-2, maxVal-minVal, maxVal, colors.lightGray, colors.gray, monitor)
  441.     monitor.setBackgroundColour(colours.black)
  442.    
  443.     monitor.setBackgroundColour(colours.blue)
  444.     monitor.setCursorPos(8,13)
  445.     monitor.write(" +1 ", monitor)
  446.  
  447.     monitor.setCursorPos(13,13)
  448.     monitor.write(" +5 ", monitor)
  449.    
  450.     monitor.setCursorPos(18,13)
  451.     monitor.write(" +10 ", monitor)
  452.    
  453.     monitor.setCursorPos(24,13)
  454.     monitor.write(" -1 ", monitor)
  455.  
  456.     monitor.setCursorPos(29,13)
  457.     monitor.write(" -5 ", monitor)
  458.    
  459.     monitor.setCursorPos(34,13)
  460.     monitor.write(" -10 ", monitor)
  461.    
  462.     monitor.setBackgroundColour(colours.black)
  463. end
  464.  
  465. function drawSettingScreen(monitorName, reactorNumber)
  466.     local monitor = peripheral.wrap(monitorName)
  467.     local currentReactor = peripheral.wrap(reactors[reactorNumber + 1])
  468.  
  469.     monitor.setBackgroundColor(colours.black)
  470.     displayW,displayH=monitor.getSize()
  471.        
  472.     -------------Title-------------------
  473.     draw_text(16, 6, "Settings", colors.blue, colors.black, monitor)
  474.    
  475.     monitor.setTextColour(colours.blue)
  476.     monitor.setCursorPos(0,7)
  477.     monitor.write(string.rep("-", displayW), monitor)
  478.     monitor.setTextColour(colours.white)
  479.    
  480.     -----------Reactor Management Enable/Disable---------------------
  481.     monitor.setCursorPos(1,8)
  482.     monitor.setTextColour(colours.yellow)
  483.     monitor.write("Reactor Management: ", monitor)
  484.     monitor.setTextColour(colours.white)
  485.     if reactorsManagement[reactorNumber + 1] == true then
  486.         monitor.setBackgroundColour(colours.blue)
  487.     else
  488.         monitor.setBackgroundColour(colours.grey)
  489.     end
  490.     monitor.setCursorPos(20,8)
  491.     monitor.write(" ON  ", monitor)
  492.  
  493.     if reactorsManagement[reactorNumber + 1] == true then
  494.         monitor.setBackgroundColour(colours.grey)
  495.     else
  496.         monitor.setBackgroundColour(colours.blue)
  497.     end
  498.     monitor.setCursorPos(25,8)
  499.     monitor.write(" OFF ", monitor)
  500.     monitor.setBackgroundColour(colours.black)
  501.    
  502.    
  503.     -----------Reactor MaxFluid Tank Level---------
  504.     if currentReactor.isActivelyCooled() then
  505.         monitor.setCursorPos(1,10)
  506.         monitor.setTextColour(colours.blue)
  507.         monitor.write("Max Fluid Tank Level:", monitor)
  508.         monitor.setTextColour(colours.white)
  509.         draw_text(22, 10, maxFluidTank.." mb", colors.white, colors.black, monitor)
  510.  
  511.         monitor.setBackgroundColour(colours.blue)
  512.  
  513.         monitor.setCursorPos(1,11)
  514.         monitor.write("|+100|", monitor)
  515.      
  516.         monitor.setCursorPos(6,11)
  517.         monitor.write("|+1000|", monitor)
  518.        
  519.         monitor.setCursorPos(12,11)
  520.         monitor.write("|+10,000|", monitor)
  521.        
  522.         monitor.setCursorPos(1,12)
  523.         monitor.write("|-100|", monitor)
  524.      
  525.         monitor.setCursorPos(6,12)
  526.         monitor.write("|-1000|", monitor)
  527.        
  528.         monitor.setCursorPos(12,12)
  529.         monitor.write("|-10,000|", monitor)
  530.        
  531.         monitor.setBackgroundColour(colours.black)
  532.     end
  533.  
  534.     -----------Reactor Levels Max/Min---------------------
  535.     if not currentReactor.isActivelyCooled() then
  536.         monitor.setCursorPos(1,11)
  537.         monitor.setTextColour(colours.blue)
  538.         monitor.write("Power Management Levels: ", monitor)
  539.  
  540.         monitor.setCursorPos(1,12)
  541.         monitor.setTextColour(colours.yellow)
  542.         monitor.write("Min Level:", monitor)
  543.         monitor.setTextColour(colours.white)
  544.         local value = minLevelPower
  545.         draw_text(12, 12, value.." RF", colors.white, colors.black, monitor)      
  546.         monitor.setBackgroundColour(colours.blue)
  547.         monitor.setCursorPos(1,13)
  548.         monitor.write("|+1|", monitor)
  549.      
  550.         monitor.setCursorPos(5,13)
  551.         monitor.write("|+100|", monitor)
  552.        
  553.         monitor.setCursorPos(11,13)
  554.         monitor.write("|+1000|", monitor)
  555.        
  556.         monitor.setCursorPos(18,13)
  557.         monitor.write("|+10k|", monitor)
  558.      
  559.         monitor.setCursorPos(24,13)
  560.         monitor.write("|+100k|", monitor)
  561.        
  562.         monitor.setCursorPos(31,13)
  563.         monitor.write("|+1mill|", monitor)
  564.        
  565.         monitor.setCursorPos(1,14)
  566.         monitor.write("|-1|", monitor)
  567.      
  568.         monitor.setCursorPos(5,14)
  569.         monitor.write("|-100|", monitor)
  570.        
  571.         monitor.setCursorPos(11,14)
  572.         monitor.write("|-1000|", monitor)
  573.        
  574.         monitor.setCursorPos(18,14)
  575.         monitor.write("|-10k|", monitor)
  576.      
  577.         monitor.setCursorPos(24,14)
  578.         monitor.write("|-100k|", monitor)
  579.        
  580.         monitor.setCursorPos(31,14)
  581.         monitor.write("|-1mill|", monitor)
  582.        
  583.        
  584.         monitor.setBackgroundColour(colours.black)
  585.        
  586.         monitor.setCursorPos(1,15)
  587.         monitor.setTextColour(colours.yellow)
  588.         monitor.write("Max Level:", monitor)
  589.         monitor.setTextColour(colours.white)
  590.         local value = maxLevelPower
  591.         draw_text(12, 15, value.." RF", colors.white, colors.black, monitor)      
  592.         monitor.setBackgroundColour(colours.blue)
  593.        
  594.         monitor.setCursorPos(1,16)
  595.         monitor.write("|+1|", monitor)
  596.      
  597.         monitor.setCursorPos(5,16)
  598.         monitor.write("|+100|", monitor)
  599.        
  600.         monitor.setCursorPos(11,16)
  601.         monitor.write("|+1000|", monitor)
  602.        
  603.         monitor.setCursorPos(18,16)
  604.         monitor.write("|+10k|", monitor)
  605.      
  606.         monitor.setCursorPos(24,16)
  607.         monitor.write("|+100k|", monitor)
  608.        
  609.         monitor.setCursorPos(31,16)
  610.         monitor.write("|+1mill|", monitor)
  611.        
  612.         monitor.setCursorPos(1,17)
  613.         monitor.write("|-1|", monitor)
  614.      
  615.         monitor.setCursorPos(5,17)
  616.         monitor.write("|-100|", monitor)
  617.        
  618.         monitor.setCursorPos(11,17)
  619.         monitor.write("|-1000|", monitor)
  620.        
  621.         monitor.setCursorPos(18,17)
  622.         monitor.write("|-10k|", monitor)
  623.      
  624.         monitor.setCursorPos(24,17)
  625.         monitor.write("|-100k|", monitor)
  626.        
  627.         monitor.setCursorPos(31,17)
  628.         monitor.write("|-1mill|", monitor)
  629.        
  630.     else
  631.         monitor.setCursorPos(1,14)
  632.         monitor.setTextColour(colours.blue)
  633.         monitor.write("Steam Management Levels: ", monitor)
  634.  
  635.         monitor.setCursorPos(1,15)
  636.         monitor.setTextColour(colours.yellow)
  637.         monitor.write("Min Level:", monitor)
  638.         monitor.setTextColour(colours.white)
  639.         local value = minLevelSteam
  640.         draw_text(12, 15, value.." mb", colors.white, colors.black, monitor)
  641.         monitor.setBackgroundColour(colours.blue)
  642.        
  643.         --Higher Values
  644.         monitor.setCursorPos(1,16)
  645.         monitor.write("|+1|", monitor)
  646.      
  647.         monitor.setCursorPos(5,16)
  648.         monitor.write("|+100|", monitor)
  649.        
  650.         monitor.setCursorPos(11,16)
  651.         monitor.write("|+1000|", monitor)
  652.        
  653.         monitor.setCursorPos(18,16)
  654.         monitor.write("|+10,000|", monitor)
  655.        
  656.         --Lower Values
  657.         monitor.setCursorPos(1,17)
  658.         monitor.write("|-1|", monitor)
  659.      
  660.         monitor.setCursorPos(5,17)
  661.         monitor.write("|-100|", monitor)
  662.        
  663.         monitor.setCursorPos(11,17)
  664.         monitor.write("|-1000|", monitor)
  665.        
  666.         monitor.setCursorPos(18,17)
  667.         monitor.write("|-10,000|", monitor)
  668.        
  669.         monitor.setBackgroundColour(colours.black)
  670.        
  671.         monitor.setCursorPos(1,18)
  672.         monitor.setTextColour(colours.yellow)
  673.         monitor.write("Max Level:", monitor)
  674.         monitor.setTextColour(colours.white)
  675.         local value = maxLevelSteam
  676.         draw_text(12, 18, value.." mb", colors.white, colors.black, monitor)
  677.        
  678.         monitor.setBackgroundColour(colours.blue)
  679.         monitor.setCursorPos(1,19)
  680.         monitor.write("|+1|", monitor)
  681.      
  682.         monitor.setCursorPos(5,19)
  683.         monitor.write("|+100|", monitor)
  684.        
  685.         monitor.setCursorPos(11,19)
  686.         monitor.write("|+1000|", monitor)
  687.        
  688.         monitor.setCursorPos(18,19)
  689.         monitor.write("|+10,000|", monitor)
  690.        
  691.         monitor.setCursorPos(1,20)
  692.         monitor.write("|-1|", monitor)
  693.      
  694.         monitor.setCursorPos(5,20)
  695.         monitor.write("|-100|", monitor)
  696.        
  697.         monitor.setCursorPos(11,20)
  698.         monitor.write("|-1000|", monitor)
  699.        
  700.         monitor.setCursorPos(18,20)
  701.         monitor.write("|-10,000|", monitor)
  702.     end
  703.     monitor.setBackgroundColour(colours.black)
  704. end
  705.  
  706. function management()
  707.     for i=1,#reactors,1 do
  708.         if reactorsManagement[i] == true then
  709.             tempReactor = peripheral.wrap(reactors[i])
  710.             if not tempReactor.isActivelyCooled() then
  711.                 energy_stored = tempReactor.getEnergyStored()
  712.                 if energy_stored > maxLevelPower then
  713.                     tempReactor.setActive(false)
  714.                 elseif energy_stored < minLevelPower then
  715.                     tempReactor.setActive(true)
  716.                 end
  717.             else
  718.                 if tempReactor.getHotFluidAmount() >= maxLevelSteam then
  719.                     tempReactor.setActive(false)
  720.                 elseif tempReactor.getHotFluidAmount() <= minLevelSteam then
  721.                     tempReactor.setActive(true)
  722.                 end
  723.             end
  724.         end
  725.     end
  726. end
  727.  
  728. function checkClickPosition(peripheralName)
  729.     local monitor = peripheral.wrap(peripheralName)
  730.     local displayW,displayH=monitor.getSize()
  731.     local index = 0
  732.         for i=1,#monitors,1 do
  733.             if monitors[i] == peripheralName then
  734.                 index = i
  735.             end
  736.         end
  737.        
  738.     if tonumber(monitorsCurrentScreen[index]) == 0 then
  739.         if mouseWidth > 1 and mouseWidth < displayW and mouseHeight > displayH - 3 and mouseHeight < displayH then
  740.             if tonumber(monitorsCurrentScreen[index]) == 0 then
  741.                 monitorsCurrentScreen[index] = "1"
  742.             end
  743.         end
  744.     elseif mouseWidth > 20 and mouseWidth < 24 and mouseHeight == 3 then
  745.         peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setActive(true)
  746.     elseif mouseWidth > 24 and mouseWidth < 28 and mouseHeight == 3 then
  747.         peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setActive(false)
  748.     elseif mouseWidth > 1 and mouseWidth < (displayW - 26) and mouseHeight == (displayH - 1) then
  749.         if tonumber(monitorsCurrentScreen[index]) > 0 then
  750.             monitorsCurrentScreen[index] = "0"
  751.         end
  752.     elseif mouseWidth > (displayW - 25) and mouseWidth < (displayW - 10) and mouseHeight == (displayH - 1) then
  753.         if tonumber(monitorsCurrentScreen[index]) == 1 then
  754.             monitorsCurrentScreen[index] = "2"
  755.         elseif tonumber(monitorsCurrentScreen[index]) == 2 then
  756.             monitorsCurrentScreen[index] = "1"
  757.         elseif tonumber(monitorsCurrentScreen[index]) == 3 then
  758.             monitorsCurrentScreen[index] = "2"
  759.         end
  760.     elseif mouseWidth > (displayW - 10) and mouseWidth < displayW and mouseHeight == (displayH - 1) then
  761.         if tonumber(monitorsCurrentScreen[index]) == 1 then
  762.             monitorsCurrentScreen[index] = "3"
  763.         elseif tonumber(monitorsCurrentScreen[index]) == 3 then
  764.             monitorsCurrentScreen[index] = "1"
  765.         elseif tonumber(monitorsCurrentScreen[index]) == 2 then
  766.             monitorsCurrentScreen[index] = "3"
  767.         end
  768.     elseif mouseWidth > (displayW - 9) and mouseWidth < (displayW - 7) and mouseHeight == 1 then
  769.         if monitorsCurrentReactor[index] > 0 then
  770.             monitorsCurrentReactor[index] = monitorsCurrentReactor[index] - 1
  771.         end
  772.     elseif mouseWidth > (displayW - 6) and mouseWidth < (displayW - 4) and mouseHeight == 1 then
  773.         if monitorsCurrentReactor[index] < table.getn(reactors) - 1 then
  774.             monitorsCurrentReactor[index] = monitorsCurrentReactor[index] + 1
  775.         end
  776.     elseif tonumber(monitorsCurrentScreen[index]) == 2 then
  777.         if mouseWidth > 9 and mouseWidth < 12 and mouseHeight == 11 then
  778.             if rodNumber == numberOfControlRods - 1 then
  779.                 rodNumber = numberOfControlRods - 1
  780.             else
  781.                 rodNumber = rodNumber + 1
  782.             end
  783.         elseif mouseWidth > 13 and mouseWidth < 16 and mouseHeight == 11 then
  784.             if rodNumber == 0 then
  785.                 rodNumber = 0
  786.             else
  787.                 rodNumber = rodNumber - 1
  788.             end
  789.            
  790.            
  791.         elseif mouseWidth > 8 and mouseWidth < 12 and mouseHeight == 13 then
  792.             if (rodLevel + 1) > 100 then
  793.                 rodLevel = 100
  794.             else
  795.                 rodLevel = rodLevel + 1
  796.             end
  797.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  798.         elseif mouseWidth > 13 and mouseWidth < 17 and mouseHeight == 13 then
  799.             if (rodLevel + 5) > 100 then
  800.                 rodLevel = 100
  801.             else
  802.                 rodLevel = rodLevel + 5
  803.             end
  804.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  805.         elseif mouseWidth > 18 and mouseWidth < 22 and mouseHeight == 13 then
  806.             if (rodLevel + 10) > 100 then
  807.                 rodLevel = 100
  808.             else
  809.                 rodLevel = rodLevel + 10
  810.             end
  811.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  812.            
  813.         elseif mouseWidth > 24 and mouseWidth < 28 and mouseHeight == 13 then
  814.             if (rodLevel - 1) < 0 then
  815.                 rodLevel = 0
  816.             else
  817.                 rodLevel = rodLevel - 1
  818.             end
  819.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  820.         elseif mouseWidth > 29 and mouseWidth < 33 and mouseHeight == 13 then
  821.             if (rodLevel - 5) < 0 then
  822.                 rodLevel = 0
  823.             else
  824.                 rodLevel = rodLevel - 5
  825.             end
  826.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  827.         elseif mouseWidth > 34 and mouseWidth < 41 and mouseHeight == 13 then
  828.             if (rodLevel - 10) < 0 then
  829.                 rodLevel = 0
  830.             else
  831.                 rodLevel = rodLevel - 10
  832.             end
  833.             peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).setControlRodLevel(rodNumber, rodLevel)
  834.         end
  835.     end
  836.    
  837.     if tonumber(monitorsCurrentScreen[index]) == 3 then
  838.         if mouseWidth > 20 and mouseWidth < 24 and mouseHeight == 8 then
  839.             reactorsManagement[monitorsCurrentReactor[index]+ 1] = true
  840.         elseif mouseWidth > 24 and mouseWidth < 28 and mouseHeight == 8 then
  841.             reactorsManagement[monitorsCurrentReactor[index]+ 1] = false
  842.         end
  843.         if not peripheral.wrap(""..reactors[monitorsCurrentReactor[index]+ 1]).isActivelyCooled() then
  844.             --Higher Values
  845.             if mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 13 then
  846.                 if (minLevelPower + 1) > 10000000 then
  847.                     minLevelPower = 10000000
  848.                 else
  849.                     minLevelPower = minLevelPower + 1
  850.                 end
  851.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 13 then
  852.                 if (minLevelPower + 100) > 10000000 then
  853.                     minLevelPower = 10000000
  854.                 else
  855.                     minLevelPower = minLevelPower + 100
  856.                 end
  857.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 13 then
  858.                 if (minLevelPower + 1000) > 10000000 then
  859.                     minLevelPower = 10000000
  860.                 else
  861.                     minLevelPower = minLevelPower + 1000
  862.                 end
  863.             elseif mouseWidth > 18 and mouseWidth < 24 and mouseHeight == 13 then
  864.                 if (minLevelPower + 10000) > 10000000 then
  865.                     minLevelPower = 10000000
  866.                 else
  867.                     minLevelPower = minLevelPower + 10000
  868.                 end
  869.             elseif mouseWidth > 24 and mouseWidth < 31 and mouseHeight == 13 then
  870.                 if (minLevelPower + 100000) > 10000000 then
  871.                     minLevelPower = 10000000
  872.                 else
  873.                     minLevelPower = minLevelPower + 100000
  874.                 end
  875.             elseif mouseWidth > 31 and mouseWidth < 36 and mouseHeight == 13 then
  876.                 if (minLevelPower + 1000000) > 10000000 then
  877.                     minLevelPower = 10000000
  878.                 else
  879.                     minLevelPower = minLevelPower + 1000000
  880.                 end
  881.            
  882.             --Lower Values
  883.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 14 then
  884.                 if (minLevelPower - 1000000) < 0 then
  885.                     minLevelPower = 0
  886.                 else
  887.                     minLevelPower = minLevelPower - 1
  888.                 end
  889.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 14 then
  890.                 if (minLevelPower - 1000000) < 0 then
  891.                     minLevelPower = 0
  892.                 else
  893.                     minLevelPower = minLevelPower - 100
  894.                 end
  895.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 14 then
  896.                 if (minLevelPower - 1000000) < 0 then
  897.                     minLevelPower = 0
  898.                 else
  899.                     minLevelPower = minLevelPower - 1000
  900.                 end
  901.             elseif mouseWidth > 18 and mouseWidth < 24 and mouseHeight == 14 then
  902.                 if (minLevelPower - 1000000) < 0 then
  903.                     minLevelPower = 0
  904.                 else
  905.                     minLevelPower = minLevelPower - 10000
  906.                 end
  907.             elseif mouseWidth > 24 and mouseWidth < 31 and mouseHeight == 14 then
  908.                 if (minLevelPower - 1000000) < 0 then
  909.                     minLevelPower = 0
  910.                 else
  911.                     minLevelPower = minLevelPower - 100000
  912.                 end
  913.             elseif mouseWidth > 31 and mouseWidth < 36 and mouseHeight == 14 then
  914.                 if (minLevelPower - 1000000) < 0 then
  915.                     minLevelPower = 0
  916.                 else
  917.                     minLevelPower = minLevelPower - 1000000
  918.                 end
  919.                
  920.             --Higher Values
  921.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 16 then
  922.                 if (minLevelPower + 1) > 10000000 then
  923.                     minLevelPower = 10000000
  924.                 else
  925.                     minLevelPower = minLevelPower + 1
  926.                 end
  927.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 16 then
  928.                 if (maxLevelPower + 100) > 10000000 then
  929.                     maxLevelPower = 10000000
  930.                 else
  931.                     maxLevelPower = maxLevelPower + 100
  932.                 end
  933.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 16 then
  934.                 if (maxLevelPower + 1000) > 10000000 then
  935.                     maxLevelPower = 10000000
  936.                 else
  937.                     maxLevelPower = maxLevelPower + 1000
  938.                 end
  939.             elseif mouseWidth > 18 and mouseWidth < 24 and mouseHeight == 16 then
  940.                 if (maxLevelPower + 10000) > 10000000 then
  941.                     maxLevelPower = 10000000
  942.                 else
  943.                     maxLevelPower = maxLevelPower + 10000
  944.                 end
  945.             elseif mouseWidth > 24 and mouseWidth < 31 and mouseHeight == 16 then
  946.                 if (maxLevelPower + 100000) > 10000000 then
  947.                     maxLevelPower = 10000000
  948.                 else
  949.                     maxLevelPower = maxLevelPower + 100000
  950.                 end
  951.             elseif mouseWidth > 31 and mouseWidth < 36 and mouseHeight == 16 then
  952.                 if (maxLevelPower + 1000000) > 10000000 then
  953.                     maxLevelPower = 10000000
  954.                 else
  955.                     maxLevelPower = maxLevelPower + 1000000
  956.                 end
  957.                
  958.             --Lower Values
  959.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 17 then
  960.                 if (maxLevelPower - 1000000) < 0 then
  961.                     maxLevelPower = 0
  962.                 else
  963.                     maxLevelPower = maxLevelPower - 1
  964.                 end
  965.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 17 then
  966.                 if (maxLevelPower - 1000000) < 0 then
  967.                     maxLevelPower = 0
  968.                 else
  969.                     maxLevelPower = maxLevelPower - 100
  970.                 end
  971.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 17 then
  972.                 if (maxLevelPower - 1000000) < 0 then
  973.                     maxLevelPower = 0
  974.                 else
  975.                     maxLevelPower = maxLevelPower - 1000
  976.                 end
  977.             elseif mouseWidth > 18 and mouseWidth < 24 and mouseHeight == 17 then
  978.                 if (maxLevelPower - 1000000) < 0 then
  979.                     maxLevelPower = 0
  980.                 else
  981.                     maxLevelPower = maxLevelPower - 10000
  982.                 end
  983.             elseif mouseWidth > 24 and mouseWidth < 31 and mouseHeight == 17 then
  984.                 if (maxLevelPower - 1000000) < 0 then
  985.                     maxLevelPower = 0
  986.                 else
  987.                     maxLevelPower = maxLevelPower - 100000
  988.                 end
  989.             elseif mouseWidth > 31 and mouseWidth < 36 and mouseHeight == 17 then
  990.                 if (maxLevelPower - 1000000) < 0 then
  991.                     maxLevelPower = 0
  992.                 else
  993.                     maxLevelPower = maxLevelPower - 1000000
  994.                 end
  995.             end
  996.         else
  997.             --------- Max Fluid Tank Levels ---------
  998.            
  999.             --Higher Values
  1000.             if mouseWidth > 1 and mouseWidth < 6 and mouseHeight == 11 then
  1001.                 if maxFluidTank >= 50000 then
  1002.                     maxFluidTank = 50000
  1003.                 else
  1004.                     maxFluidTank = maxFluidTank + 100
  1005.                     if maxLevelSteam < maxFluidTank then
  1006.                         maxLevelSteam = maxFluidTank
  1007.                     end
  1008.                 end
  1009.             elseif mouseWidth > 6 and mouseWidth < 12 and mouseHeight == 11 then
  1010.                 if maxFluidTank >= 50000 then
  1011.                     maxFluidTank = 50000
  1012.                 else
  1013.                     maxFluidTank = maxFluidTank + 1000
  1014.                     if maxLevelSteam < maxFluidTank then
  1015.                         maxLevelSteam = maxFluidTank
  1016.                     end
  1017.                 end
  1018.             elseif mouseWidth > 12 and mouseWidth < 20 and mouseHeight == 11 then
  1019.                 if maxFluidTank >= 50000 then
  1020.                     maxFluidTank = 50000
  1021.                 else
  1022.                     maxFluidTank = maxFluidTank + 10000
  1023.                     if maxLevelSteam < maxFluidTank then
  1024.                         maxLevelSteam = maxFluidTank
  1025.                     end
  1026.                 end
  1027.            
  1028.             --Lower Values
  1029.             elseif mouseWidth > 1 and mouseWidth < 6 and mouseHeight == 12 then
  1030.                 if maxFluidTank <= 0 then
  1031.                     maxFluidTank = 0
  1032.                 else
  1033.                     maxFluidTank = maxFluidTank - 1
  1034.                     if maxLevelSteam > maxFluidTank then
  1035.                         maxLevelSteam = maxFluidTank
  1036.                     end
  1037.                 end
  1038.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 12 then
  1039.                 if maxFluidTank <= 0 then
  1040.                     maxFluidTank = 0
  1041.                 else
  1042.                     maxFluidTank = maxFluidTank - 100
  1043.                     if maxLevelSteam > maxFluidTank then
  1044.                         maxLevelSteam = maxFluidTank
  1045.                     end
  1046.                 end
  1047.             elseif mouseWidth > 11 and mouseWidth < 20 and mouseHeight == 12 then
  1048.                 if maxFluidTank <= 0 then
  1049.                     maxFluidTank = 0
  1050.                 else
  1051.                     maxFluidTank = maxFluidTank - 10000
  1052.                     if maxLevelSteam > maxFluidTank then
  1053.                         maxLevelSteam = maxFluidTank
  1054.                     end
  1055.                 end
  1056.                
  1057.             --------- Steam Levels ---------
  1058.            
  1059.             --Higher Values
  1060.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 16 then
  1061.                 if (minLevelSteam + 1) > maxFluidTank then
  1062.                     minLevelSteam = maxFluidTank
  1063.                 else
  1064.                     minLevelSteam = minLevelSteam + 1
  1065.                 end
  1066.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 16 then
  1067.                 if (minLevelSteam + 100) > maxFluidTank then
  1068.                     minLevelSteam = maxFluidTank
  1069.                 else
  1070.                     minLevelSteam = minLevelSteam + 100
  1071.                 end
  1072.             elseif mouseWidth > 10 and mouseWidth < 18 and mouseHeight == 16 then
  1073.                 if (minLevelSteam + 1000) > maxFluidTank then
  1074.                     minLevelSteam = maxFluidTank
  1075.                 else
  1076.                     minLevelSteam = minLevelSteam + 1000
  1077.                 end
  1078.             elseif mouseWidth > 18 and mouseWidth < 26 and mouseHeight == 16 then
  1079.                 if (minLevelSteam + 10000) > maxFluidTank then
  1080.                     minLevelSteam = maxFluidTank
  1081.                 else
  1082.                     minLevelSteam = minLevelSteam + 10000
  1083.                 end
  1084.             --Lower Values
  1085.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 17 then
  1086.                 if (minLevelSteam - 1) < 0 then
  1087.                     minLevelSteam = 0
  1088.                 else
  1089.                     minLevelSteam = minLevelSteam - 1
  1090.                 end
  1091.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 17 then
  1092.                 if (minLevelSteam - 100) < 0 then
  1093.                     minLevelSteam = 0
  1094.                 else
  1095.                     minLevelSteam = minLevelSteam - 100
  1096.                 end
  1097.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 17 then
  1098.                 if (minLevelSteam - 1000) < 0 then
  1099.                     minLevelSteam = 0
  1100.                 else
  1101.                     minLevelSteam = minLevelSteam - 1000
  1102.                 end
  1103.             elseif mouseWidth > 18 and mouseWidth < 26 and mouseHeight == 17 then
  1104.                 if (minLevelSteam - 10000) < 0 then
  1105.                     minLevelSteam = 0
  1106.                 else
  1107.                     minLevelSteam = minLevelSteam - 10000
  1108.                 end
  1109.            
  1110.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 19 then
  1111.                 if (maxLevelSteam + 1) > maxFluidTank then
  1112.                     maxLevelSteam = maxFluidTank
  1113.                 else
  1114.                     maxLevelSteam = maxLevelSteam + 1
  1115.                 end
  1116.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 19 then
  1117.                 if (maxLevelSteam + 100) > maxFluidTank then
  1118.                     maxLevelSteam = maxFluidTank
  1119.                 else
  1120.                     maxLevelSteam = maxLevelSteam + 100
  1121.                 end
  1122.             elseif mouseWidth > 10 and mouseWidth < 18 and mouseHeight == 19 then
  1123.                 if (maxLevelSteam + 1000) > maxFluidTank then
  1124.                     maxLevelSteam = maxFluidTank
  1125.                 else
  1126.                     maxLevelSteam = maxLevelSteam + 1000
  1127.                 end
  1128.             elseif mouseWidth > 18 and mouseWidth < 26 and mouseHeight == 19 then
  1129.                 if (maxLevelSteam + 10000) > maxFluidTank then
  1130.                     maxLevelSteam = maxFluidTank
  1131.                 else
  1132.                     maxLevelSteam = maxLevelSteam + 10000
  1133.                 end
  1134.             --Lower Values
  1135.             elseif mouseWidth > 1 and mouseWidth < 5 and mouseHeight == 20 then
  1136.                 if (maxLevelSteam - 1) < 0 then
  1137.                     maxLevelSteam = 0
  1138.                 else
  1139.                     maxLevelSteam = maxLevelSteam - 1
  1140.                 end
  1141.             elseif mouseWidth > 5 and mouseWidth < 11 and mouseHeight == 20 then
  1142.                 if (maxLevelSteam - 100) < 0 then
  1143.                     maxLevelSteam = 0
  1144.                 else
  1145.                     maxLevelSteam = maxLevelSteam - 100
  1146.                 end
  1147.             elseif mouseWidth > 11 and mouseWidth < 18 and mouseHeight == 20 then
  1148.                 if (maxLevelSteam - 1000) < 0 then
  1149.                     maxLevelSteam = 0
  1150.                 else
  1151.                     maxLevelSteam = maxLevelSteam - 1000
  1152.                 end
  1153.             elseif mouseWidth > 18 and mouseWidth < 26 and mouseHeight == 20 then
  1154.                 if (maxLevelSteam - 10000) < 0 then
  1155.                     maxLevelSteam = 0
  1156.                 else
  1157.                     maxLevelSteam = maxLevelSteam - 10000
  1158.                 end
  1159.             end
  1160.         end
  1161.     end
  1162.     sleep(1.0)
  1163. end
  1164.  
  1165. function mainMenu()
  1166.     terminalOutput()
  1167.     initPeripherals()
  1168.     while true do
  1169.         for i=1,#monitors,1 do
  1170.             monitor = peripheral.wrap(monitors[i])
  1171.             displayW,displayH=monitor.getSize()
  1172.             if displayH == 26 and displayW == 39 then
  1173.                 for i=1,#monitorsCurrentScreen,1 do
  1174.                     if monitorsCurrentScreen[i] == "0" then
  1175.                         drawMainScreen(monitors[i], monitorsCurrentReactor[i])
  1176.                     elseif monitorsCurrentScreen[i] == "1" then
  1177.                         drawControlScreen(monitors[i], monitorsCurrentReactor[i], i)
  1178.                         drawDisplayScreen(monitors[i], monitorsCurrentReactor[i])
  1179.                     elseif monitorsCurrentScreen[i] == "2" then
  1180.                         drawControlScreen(monitors[i], monitorsCurrentReactor[i], i)
  1181.                         drawRodScreen(monitors[i], monitorsCurrentReactor[i])
  1182.                     elseif monitorsCurrentScreen[i] == "3" then
  1183.                         drawControlScreen(monitors[i], monitorsCurrentReactor[i], i)
  1184.                         drawSettingScreen(monitors[i], monitorsCurrentReactor[i])
  1185.                     end
  1186.                 end
  1187.                 management()
  1188.             else
  1189.                 print("This program is built for a 4x4 monitors only!")
  1190.                 return
  1191.             end
  1192.         end
  1193.         sleep(1.0)
  1194.     end
  1195. end
  1196.  
  1197. function events()
  1198.     while true do
  1199.         event,p1,p2,p3 = os.pullEvent()
  1200.         if event=="monitor_touch" then
  1201.             mouseWidth = p2 -- sets mouseWidth
  1202.             mouseHeight = p3 -- and mouseHeight
  1203.             checkClickPosition(p1) -- this runs our function
  1204.         elseif event=="peripheral" then
  1205.             terminalOutput()
  1206.             initPeripherals()
  1207.         elseif event=="peripheral_detach" then
  1208.             terminalOutput()
  1209.             initPeripherals()
  1210.         end
  1211.     end
  1212. end
  1213.  
  1214. parallel.waitForAny(mainMenu,events)
Advertisement
Add Comment
Please, Sign In to add comment