Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = peripheral.wrap("back")
- local display = peripheral.wrap("right")
- local tanks = {
- reactor = "reactor_fluid_port_0",
- coolantA = "rcirontankvalvetile_2",
- coolantB = "rcirontankvalvetile_3",
- distilledA = "rcirontankvalvetile_5",
- distilledB = "rcirontankvalvetile_1"
- }
- function tryTankLevel(tank)
- return com.callRemote(tank, "getTankInfo")[1].contents.amount
- end
- function getReactorHot()
- local empty, level = pcall(function () return com.callRemote(tanks.reactor, "getTankInfo")[2].contents.amount end)
- if (not empty) then
- return 0
- else
- return level
- end
- end
- function getReactorCold()
- local empty, level = pcall(function () return com.callRemote(tanks.reactor, "getTankInfo")[1].contents.amount end)
- if (not empty) then
- return 0
- else
- return level
- end
- end
- function getTankLevel(tank)
- local empty, level = pcall(tryTankLevel, tank)
- if (not empty) then
- return 0
- else
- return level
- end
- end
- local colorValue = 0
- function toggleColor(color)
- if (rs.testBundledInput("bottom", color)) then
- rs.setBundledOutput("bottom", colorValue - color)
- colorValue = colorValue - color
- else
- rs.setBundledOutput("bottom", colorValue + color)
- colorValue = colorValue + color
- end
- end
- function printAtMonitor(x, y, color, text)
- display.setTextColor(color)
- display.setCursorPos(x, y)
- display.write(text)
- end
- function printAt(x,y,color,text)
- term.setTextColor(color)
- term.setCursorPos(x, y)
- term.write(text)
- end
- function reactorDisplay()
- local run = true
- while true do
- local ReactorCold = getReactorCold()
- local ReactorHot = getReactorHot()
- local ReactorOn = rs.testBundledInput("bottom", colors.green)
- local coolant = {
- tankA = getTankLevel(tanks.coolantA),
- tankB = getTankLevel(tanks.coolantB),
- A1 = rs.testBundledInput("bottom", colors.white),
- A2 = rs.testBundledInput("bottom", colors.orange),
- B1 = rs.testBundledInput("bottom", colors.magenta),
- B2 = rs.testBundledInput("bottom", colors.lightBlue)
- }
- local distilled = {
- tankA = getTankLevel(tanks.distilledA),
- tankB = getTankLevel(tanks.distilledB),
- A1 = rs.testBundledInput("bottom", colors.yellow),
- A2 = rs.testBundledInput("bottom", colors.lime),
- B1 = rs.testBundledInput("bottom", colors.pink),
- B2 = rs.testBundledInput("bottom", colors.gray)
- }
- local turbine = {
- A1 = rs.testBundledInput("bottom", colors.cyan),
- A2 = rs.testBundledInput("bottom", colors.purple),
- B1 = rs.testBundledInput("bottom", colors.blue),
- B2 = rs.testBundledInput("bottom", colors.brown)
- }
- display.clear()
- printAtMonitor(1,1,colors.white,"Reactor Levels:")
- printAtMonitor(2,2,colors.red, "Hot: "..ReactorHot)
- printAtMonitor(2,3,colors.cyan, "Cold: "..ReactorCold)
- printAtMonitor(1,4,colors.white, "Tank Levels:")
- printAtMonitor(2,5,colors.cyan, "CoolA: "..coolant.tankA)
- printAtMonitor(2,6,colors.cyan, "CoolB: "..coolant.tankB)
- printAtMonitor(2,7,colors.lightBlue, "DistA: "..distilled.tankA)
- printAtMonitor(2,8,colors.lightBlue, "DistB: "..distilled.tankB)
- printAtMonitor(1,9, colors.white, "Turbines:")
- printAtMonitor(2,10, colors.yellow, "A1[ ] B1[ ]")
- printAtMonitor(2,11, colors.yellow, "A2[ ] B2[ ]")
- if (turbine.A1) then
- printAtMonitor(5,10, colors.lime, "On")
- else
- printAtMonitor(5,10, colors.red, "Off")
- end
- if (turbine.A2) then
- printAtMonitor(5,11, colors.lime, "On")
- else
- printAtMonitor(5,11, colors.red, "Off")
- end
- if (turbine.B1) then
- printAtMonitor(13,10, colors.lime, "On")
- else
- printAtMonitor(13,10, colors.red, "Off")
- end
- if (turbine.B2) then
- printAtMonitor(13,11, colors.lime, "On")
- else
- printAtMonitor(13,11, colors.red, "Off")
- end
- printAtMonitor(26,4,colors.white, "-------")
- printAtMonitor(19,5,colors.white, "--- | | ---")
- printAtMonitor(19,6,colors.white, "|A| | | |B|")
- printAtMonitor(19,7,colors.white, "--- | | ---")
- printAtMonitor(26,8,colors.white, "-------")
- printAtMonitor(19,1,colors.cyan, "--[ ]")
- printAtMonitor(26,1,colors.red, "-- --")
- printAtMonitor(33,1,colors.cyan, "[ ]--")
- printAtMonitor(19,2,colors.cyan, "|")
- printAtMonitor(27,2,colors.red, "| |")
- printAtMonitor(29,2,colors.white,"1")
- printAtMonitor(39,2,colors.cyan, "|")
- printAtMonitor(19,3,colors.cyan, "|")
- printAtMonitor(27,3,colors.red, "| |")
- printAtMonitor(39,3,colors.cyan, "|")
- printAtMonitor(19,4,colors.cyan, "|")
- printAtMonitor(39,4,colors.cyan, "|")
- printAtMonitor(22,5,colors.cyan, "----")
- printAtMonitor(33,5,colors.cyan, "----")
- printAtMonitor(22,7,colors.cyan, "----")
- printAtMonitor(33,7,colors.cyan, "----")
- printAtMonitor(19,8,colors.cyan, "|")
- printAtMonitor(39,8,colors.cyan, "|")
- printAtMonitor(19,9,colors.cyan, "|")
- printAtMonitor(27,9,colors.red, "| |")
- printAtMonitor(39,9,colors.cyan, "|")
- printAtMonitor(19,10,colors.cyan, "|")
- printAtMonitor(27,10,colors.red, "| |")
- printAtMonitor(29,10,colors.white, "2")
- printAtMonitor(39,10,colors.cyan, "|")
- printAtMonitor(19,11,colors.cyan, "--[ ]")
- printAtMonitor(26,11,colors.red, "-- --")
- printAtMonitor(33,11,colors.cyan, "[ ]--")
- printAtMonitor(20,3,colors.lightBlue, "-[ ]")
- printAtMonitor(20,4,colors.lightBlue, "| |")
- printAtMonitor(33,3,colors.lightBlue, "[ ]-")
- printAtMonitor(36,4,colors.lightBlue, "| |")
- printAtMonitor(20,8,colors.lightBlue, "| |")
- printAtMonitor(20,9,colors.lightBlue, "-[ ]")
- printAtMonitor(36,8,colors.lightBlue, "| |")
- printAtMonitor(33,9,colors.lightBlue, "[ ]-")
- if (coolant.A1) then
- printAtMonitor(22,1,colors.lime, "On")
- else
- printAtMonitor(22,1,colors.red, "Off")
- end
- if (coolant.A2) then
- printAtMonitor(22,11,colors.lime, "On")
- else
- printAtMonitor(22,11,colors.red, "Off")
- end
- if (coolant.B1) then
- printAtMonitor(34,1,colors.lime, "On")
- else
- printAtMonitor(34,1,colors.red, "Off")
- end
- if (coolant.B2) then
- printAtMonitor(34,11,colors.lime, "On")
- else
- printAtMonitor(34,11,colors.red, "Off")
- end
- if (ReactorOn) then
- printAtMonitor(28,6,colors.lime, "On")
- else
- printAtMonitor(28,6,colors.red, "Off")
- end
- if (distilled.A1) then
- printAtMonitor(22,3,colors.lime, "On")
- else
- printAtMonitor(22,3,colors.red, "Off")
- end
- if (distilled.A2) then
- printAtMonitor(22,9,colors.lime, "On")
- else
- printAtMonitor(22,9,colors.red, "Off")
- end
- if (distilled.B1) then
- printAtMonitor(34,3,colors.lime,"On")
- else
- printAtMonitor(34,3,colors.red,"Off")
- end
- if (distilled.B2) then
- printAtMonitor(34,9,colors.lime,"On")
- else
- printAtMonitor(34,9,colors.red,"Off")
- end
- if (run) then
- printAtMonitor(1,12, colors.white, "Running")
- end
- run = not run
- sleep(1)
- end
- end
- function reactorControls()
- local cursor = 1
- local states = {"Off","Off","Off","Off","Off","Off","Off","Off","Off"}
- rs.setBundledOutput("bottom", 0)
- rs.setOutput("left", false)
- while true do
- term.clear()
- printAt(1,1,colors.white,"Monitor")
- printAt(1,2,colors.white, "CoolantA1")
- printAt(1,3,colors.white, "CoolantA2")
- printAt(1,4,colors.white, "CoolantB1")
- printAt(1,5,colors.white, "CoolantB2")
- printAt(1,6,colors.white, "DistilledA1")
- printAt(1,7,colors.white, "DistilledA2")
- printAt(1,8,colors.white, "DistilledB1")
- printAt(1,9,colors.white, "DistilledB2")
- printAt(1,10,colors.white, "RemoveCells")
- printAt(1,11,colors.white, "Shutdown")
- printAt(12,cursor, colors.white, "[ ]")
- for i = 1,9 do
- if (states[i] == "Off") then
- printAt(13,i,colors.red, states[i])
- else
- printAt(13,i,colors.lime, states[i])
- end
- end
- local event, keyNum = os.pullEvent("key")
- if (keyNum == 200) then
- cursor = cursor - 1
- if (cursor == 0) then
- cursor = 11
- end
- end
- if (keyNum == 208) then
- cursor = cursor + 1
- if (cursor == 12) then
- cursor = 1
- end
- end
- if (keyNum == 28) then
- if (cursor == 1) then
- rs.setOutput("left", not rs.getOutput("left"))
- end
- if (cursor == 2) then
- toggleColor(colors.white)
- end
- if (cursor == 3) then
- toggleColor(colors.orange)
- end
- if (cursor == 4) then
- toggleColor(colors.magenta)
- end
- if (cursor == 5) then
- toggleColor(colors.lightBlue)
- end
- if (cursor == 6) then
- toggleColor(colors.yellow)
- end
- if (cursor == 7) then
- toggleColor(colors.lime)
- end
- if (cursor == 8) then
- toggleColor(colors.pink)
- end
- if (cursor == 9) then
- toggleColor(colors.gray)
- end
- if (cursor == 10 and not rs.testBundledInput("bottom", colors.green)) then
- toggleColor(colors.black)
- term.clear()
- printAt(1,1,colors.white, "Removing Depleted Cells")
- sleep(7)
- toggleColor(colors.black)
- end
- if (cursor == 11 and not rs.testBundledInput("bottom", colors.green)) then
- rs.setBundledOutput("bottom", 0)
- term.clear()
- printAt(1,1,colors.white, "Goodbye!")
- sleep(1)
- term.clear()
- return
- end
- if (cursor < 10 and states[cursor] == "Off") then
- states[cursor] = "On"
- else
- states[cursor] = "Off"
- end
- end
- end
- end
- parallel.waitForAny(reactorControls,reactorDisplay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement