Last active
March 8, 2021 22:30
-
-
Save Oct0bass/812a28ebea4bbf45fb363eec2c83ee0d to your computer and use it in GitHub Desktop.
Reactor Control Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local reactor = peripheral.find("fissionReactorLogicAdapter") | |
-- Settings | |
local reset_side = "front" -- Side the reset button is on | |
local alarm_side = "left" -- Side the Alarm is on | |
local coolant_pipe_side = "right" -- Side a redstone torch powering the pipe with emergency coolant is on | |
function emergency_shutdown() | |
if reactor.getStatus() then reactor.scram() end | |
redstone.setAnalogOutput(alarm_side, 15) | |
end | |
while true do | |
term.setCursorPos(1,1) | |
print("Temperature: " .. reactor.getTemperature()) | |
print("Fuel: " .. reactor.getFuel().amount) | |
print("Waste: " .. reactor.getWaste().amount) | |
if reactor.getWaste().amount >= reactor.getWasteCapacity() then | |
emergency_shutdown() | |
print("CRITICAL: Excess waste, shutting down") | |
end | |
if reactor.getTemperature() >= 1200 then | |
emergency_shutdown() | |
redstone.setAnalogOutput(coolant_pipe_side, 15) | |
print("CRITICAL: Dangerous temperatures, shutting down") | |
end | |
if reactor.getDamagePercent() >= 100 then | |
emergency_shutdown() | |
print("MELTDOWN IMMINENT") | |
end | |
if redstone.getAnalogInput(reset_side) > 0 and not reactor.getStatus() then | |
reactor.activate() | |
redstone.setAnalogOutput(alarm_side, 0) | |
redstone.setAnalogOutput(coolant_pipe_side, 0) | |
print("Resetting") | |
term.clear() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment