Computercraft script to control Fission Reactors from Mekanism
Credit for the original script goes to @InternetUnexplorer
I've added the modified Programs to this repo, you can also use these directly instead of editing it yourself, be sure to copy the link to the RAW FILE!
- Get yourself an Advanced Computer, 18 Monitors (OPTIONAL), at least 3 Wired Modems and some Networking Cable
- Connect the wired modems to the Fission Reactor Logic Adapter, the Turbine Valve and the Computer (Additionally to the Displays if they are not adjasoned to the Computer)
- Right click on all Modems. You should get a message in chat that the devices are now on the network
- open the Computer and type
wget https://gist.githubusercontent.com/InternetUnexplorer/ea13f1713d325b914126bcfb9b35e6fd/raw/22178936686a875601f31741d6b2de385d3aa86f/reactor.lua
- If you have Monitors connected, start the Program like this:
monitor monitor_1 reactor.lua
(If the Monitors are adjasoned to the Computer, you can usemonitor left/right/top/bottom/back reactor.lua
depending on where the Monitors are positioned, use the correct direction) - Place a Lever on top of the Computer and flick it to start monitoring your reactor and turbine
You may want to remove the turbine monitoring from the script if you don't have a turbine or maybe you have the turbine set to "dump excess steam" or something. If you want to remove the Turbine from the Monitoring, you will need to remove a couple lines of code
- Open the Program with
edit reactor.lua
- find and remove these lines of code:
add_rule("TURBINE ENERGY LEVEL <= 95%", function()
local value = string.format("%3d%%", math.ceil(data.turbine_energy * 100))
return data.turbine_energy <= 0.95, value
end)
turbine_energy = turbine.getEnergyFilledPercentage(),
turbine = peripheral.find("turbineValve")
elseif data.turbine_energy == nil then
-- Turbine is not connected
state = STATES.UNKNOWN
In case you want to add the fuel level as a shutdown requirement as well. Note that by default the reactor will stop anyway if it has no fuel. I've just added the option to stop it, if the fuel level drops below 10%.
Here too, you will need to edit the Program a bit
- Open the Program with
edit reactor.lua
- Add these lines of code:
add_rule("REACTOR FUEL LEVEL >= 10%", function()
local value = string.format("%3d%%", math.ceil(data.reactor_fuel * 100))
return data.reactor_fuel >= 0.10, value
end)
these should be added below this code block (roughly on line 49):
add_rule("TURBINE ENERGY LEVEL <= 95%", function()
local value = string.format("%3d%%", math.ceil(data.turbine_energy * 100))
return data.turbine_energy <= 0.95, value
end)
Add this line as well:
reactor_fuel = reactor.getFuelFilledPercentage(),
Just Below this line (roughly on line 73):
reactor_waste = reactor.getWasteFilledPercentage(),
In some cases, you may want to have a redstone signal if the reactor has stopped, this is fairly easy to achieve:
- Open the Program with
edit reactor.lua
- Add these lines of code:
redstone.setOutput("left", true)
redstone.setOutput("left", false)
inside this code block like this (roughly on line 124):
if state == STATES.READY then
colored("READY, flip lever to start", colors.blue)
redstone.setOutput("left", false)
elseif state == STATES.RUNNING then
colored("RUNNING, flip lever to stop", colors.green)
redstone.setOutput("left", false)
elseif state == STATES.ESTOP and not all_rules_met() then
colored("EMERGENCY STOP, safety rules violated", colors.red)
redstone.setOutput("left", true)
elseif state == STATES.ESTOP then
colored("EMERGENCY STOP, toggle lever to reset", colors.red)
redstone.setOutput("left", true)
end -- STATES.UNKNOWN cases handled above
now, the computer outputs a redstone signal out of its left side as soon as the reactor gets shut down automatically by the program