Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Pulse Thermal Nuclear Reactor Control System
- --by 0xShellcode (known in game as Mr_Athans)
- --Pastebin New:
- --Pastebin old: https://pastebin.com/ADVmKVeY
- ----------------------------
- local rupsd = false --reactor user power switch detect
- local rpp = false --reactor primary power
- local pssd = false --power suppy signal detect
- local tm1sd = false --thermal monitor 1 signal detect
- local tm2sd = false --thermal monitor 2 signal detect
- local tm3sd = false --thermal monitor 3 signal detect
- local tm4sd = false --thermal monitor 4 signal detect
- local cs1 = false --coolant set 1 signal
- local cs2 = false --coolant set 2 signal
- local cs3 = false --coolant set 3 signal
- local cs4 = false --coolant set 4 signal
- local clv = false --coolant lock valves
- local tmlpd = false --thermal monitor low power detect
- local tmbp1 = false --thermal monitor backup power 1 signal
- local tmbp2 = false --thermal monitor backup power 2 signal
- local dwrfs = false --distilled water refill system signal
- local cycle = 0 --reactor start cycle
- local seconds = 60 --reactor startup length
- local startcycle = 0 --reactor startup cycle
- local startuptimer = false --reactor startup timer
- local powerdown = true --reactor - powerdown state
- local cooldown = false --reactor - cooldown state
- local shutdown = false --reactor - shutdown state
- local cableSide = "bottom" --bundled cable input side
- mon = peripheral.wrap("top") --monitor output side
- mon.restore = term.current() --set current built-in monitor to mon.restore
- mon.setCursorPos(1,1) --set cursor position to top left
- mon.setTextScale(.5) --change text scale to small
- term.redirect(mon) --redirects screen output to mon
- redstone.setBundledOutput (cableSide, 0) --disables all output signals from computer before starting loop
- while true do
- print("Pulse Thermal Nuclear Reactor 1 Control - Cycle ", cycle)
- --Reactor User Power Switch Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.cyan) then
- print(" Reactor User Power Switch - Enabled")
- rupsd = true
- else
- print(" Reactor User Power Switch - Disabled")
- rupsd = false
- end
- --Reactor Primary Power On/Off
- if colors.test (redstone.getBundledInput(cableSide), colors.white) then
- print(" Reactor Powered-On Status - On")
- rpp = true
- else
- print(" Reactor Powered-On Status - Off")
- rpp = false
- end
- --Power Storage Full Signal Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.brown) then
- print(" Power Storage Capacity Full - Yes", "\n")
- pssd = true
- else
- print(" Power Storage Capacity Full - No", "\n")
- pssd = false
- end
- --Thermal Monitor 1 Signal Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.purple) then
- print(" Thermal Monitor 1 Detection - On")
- tm1sd = true
- else
- print(" Thermal Monitor 1 Detection - Off")
- tm1sd = false
- end
- --Thermal Monitor 2 Signal Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.blue) then
- print(" Thermal Monitor 2 Detection - On")
- tm2sd = true
- else
- print(" Thermal Monitor 2 Detection - Off")
- tm2sd = false
- end
- --Thermal Monitor 3 Signal Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.lime) then
- print(" Thermal Monitor 3 Detection - On")
- tm3sd = true
- else
- print(" Thermal Monitor 3 Detection - Off")
- tm3sd = false
- end
- --Thermal Monitor 4 Signal Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.yellow) then
- print(" Thermal Monitor 4 Detection - On (Shutdown)", "\n")
- tm4sd = true
- else
- print(" Thermal Monitor 4 Detection - Off", "\n")
- tm4sd = false
- end
- ----------------------------
- --Coolant Set 1 On/Off Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.pink) then
- print(" Coolant System 1 - On")
- cs1 = true
- else
- print(" Coolant System 1 - Off")
- cs1 = false
- end
- --Coolant Set 2 On/Off Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.red) then
- print(" Coolant System 2 - On")
- cs2 = true
- else
- print(" Coolant System 2 - Off")
- cs2 = false
- end
- --Coolant Set 3 On/Off Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.orange) then
- print(" Coolant System 3 - On")
- cs3 = true
- else
- print(" Coolant System 3 - Off")
- cs3 = false
- end
- --Coolant Set 4 On/Off Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.black) then
- print(" Coolant System 4 - On")
- cs4 = true
- else
- print(" Coolant System 4 - Off")
- cs4 = false
- end
- --Coolant Lock Valves (Hot coolant side next to heat exchangers)
- if colors.test (redstone.getBundledInput(cableSide), colors.lightBlue) then
- print(" Coolant Lock Valves - Open", "\n")
- clv = true
- else
- if (startuptimer==true) then
- print(" Coolant Lock Valves - Closed ", startcycle, "/", (seconds*4), "\n")
- elseif (startuptimer==false) then
- print(" Coolant Lock Valves - Closed", "\n")
- end
- clv = false
- end
- ----------------------------
- --Thermal Monitor Low Power Detect
- if colors.test (redstone.getBundledInput(cableSide), colors.green) then
- print(" Thermal Monitor Low Power - Yes")
- tmlpd = true
- else
- print(" Thermal Monitor Low Power - No")
- tmlpd = false
- end
- --Thermal Monitor Backup Power 1 On/Off
- if colors.test (redstone.getBundledInput(cableSide), colors.magenta) then
- print(" Thermal Monitor Backup Power 1 - On")
- tmbp1 = true
- else
- print(" Thermal Monitor Backup Power 1 - Off")
- tmbp1 = false
- end
- --Thermal Monitor Backup Power 2 On/Off
- if colors.test (redstone.getBundledInput(cableSide), colors.gray) then
- print(" Thermal Monitor Backup Power 2 - On")
- tmbp2 = true
- else
- print(" Thermal Monitor Backup Power 2 - Off")
- tmbp2 = false
- end
- --Distilled Water Refill System On/Off
- if colors.test (redstone.getBundledInput(cableSide), colors.lightGray) then
- print(" Distilled Water Refill System - On", "\n")
- dwrfs = true
- else
- print(" Distilled Water Refill System - Off", "\n")
- dwrfs = false
- end
- ----------------------------
- --Reactor Power On and Cooldown Logic
- local run = false
- --Thermal Monitor Cooldown and Shutdown Logic --
- if (tm2sd==false) and (shutdown==false) then
- cooldown = false
- end
- if (tm3sd==true) then
- cooldown = true
- end
- if (tm4sd==true) then
- shutdown = true
- end
- --Control Logic --
- if (rupsd==true) and (cooldown==false) and (shutdown==false) and (pssd==false) then --if Reactor User Power Switch enabled, cooldown off, shutdown off, and power supply not full power on reactor
- print(" Reactor Powered-On: Generating Thermal Power")
- run = true
- elseif (rupsd==true) and (cooldown==true) and (shutdown==false) and (pssd==false) then
- print(" Reactor Powered-On: Maintaining Thermal Power")
- run = true
- elseif (pssd==true) then
- print(" Run condition fault: Power Supply is Full")
- run = false
- elseif (shutdown==true) then
- print(" Reactor Powered-Off: Shutdown Temp Triggered")
- shutdown = true
- run = false
- else
- print(" Reactor Powered-Off: User Disabled")
- redstone.setBundledOutput (cableSide, 0)
- run = false
- end
- --Run Logic --
- if (run==true) then
- --Coolant Lock Valves Timer Trigger
- if (powerdown==true) then
- startuptimer = true
- powerdown = false
- end
- --Coolant Lock Values Timer Logic
- if (startuptimer==true) and (startcycle <= (seconds * 4)) then
- startcycle = startcycle + 1
- clv = false
- elseif (startuptimer==true) and (startcycle > (seconds * 4)) then
- startuptimer = false
- startcycle = 0
- clv = true
- elseif (startuptimer==false) then
- startuptimer = false
- startcycle = 0
- clv = true
- end
- --Reactor State and output to multiple colors
- if (cooldown==false) then
- print(" Reactor State: Increasing Thermal Power")
- if (clv==true) then
- redstone.setBundledOutput (cableSide, colors.combine(colors.white, colors.pink, colors.red, colors.orange, colors.black, colors.lightBlue))
- else
- redstone.setBundledOutput (cableSide, colors.combine(colors.white, colors.pink, colors.red, colors.orange, colors.black))
- end
- powerdown = false
- elseif (cooldown==true) then
- print(" Reactor State: Decreasing Thermal Power")
- if (clv==true) then
- redstone.setBundledOutput (cableSide, colors.combine(colors.pink, colors.red, colors.orange, colors.black, colors.lightBlue))
- else
- redstone.setBundledOutput (cableSide, colors.combine(colors.pink, colors.red, colors.orange, colors.black))
- end
- powerdown = false
- end
- else -- run = false
- if (shutdown==true) then
- print(" Reactor State: Shutdown Triggered, Reset Reactor")
- redstone.setBundledOutput (cableSide, 0)
- powerdown = true
- startuptimer = false
- startcycle = 0
- elseif (pssd==true) then
- print(" Reactor State: Power Capacity Full")
- redstone.setBundledOutput (cableSide, 0)
- powerdown = true
- startuptimer = false
- startcycle = 0
- else
- print(" Reactor State: Reactor Powered-Down")
- powerdown = true
- startuptimer = false
- startcycle = 0
- end
- end
- ---------------------------------
- cycle = cycle + 1
- os.sleep(.25)
- term.clear()
- term.setCursorPos(1,1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement