Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reactor = {}
- capacitorBank = {}
- local function init()
- --TODO: Search peripheral.getNames() to discover the names automatically.
- reactor = peripheral.wrap("BigReactors-Reactor_0")
- if reactor == nil then
- print("Can't find a reactor!")
- return false
- end
- -- could be handy later
- --reactor.setAllControlRodLevels(90)
- capacitorBank = peripheral.wrap("bottom")
- if capacitorBank == nil then
- print("Can't find a capacitor bank!")
- return false
- end
- return true
- end
- local function maybeTogglePower()
- local charge = capacitorBank.getEnergyStored() / capacitorBank.getMaxEnergyStored()
- if charge < 0.2 then
- reactor.setActive(true)
- elseif charge > 0.8 then
- reactor.setActive(false)
- end
- end
- if not init() then return end
- while true do
- maybeTogglePower()
- os.sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement