Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allNames = peripheral.getNames()
- function getReactorName()
- for x = 1, #allNames do
- if string.match(allNames[x], "_Reactor_") then
- return allNames[x]
- end
- end
- end
- reactorName = getReactorName()
- if reactorName == nil then
- write("Can't find 'Bigger Reactors' reactor")
- exit()
- else
- write("Found reactor\n")
- end
- reactor = peripheral.wrap(reactorName)
- function monitorPower()
- while true do
- currentRodPercent = reactor.getControlRod(0).level()
- batteryLevel = reactor.battery().stored() / reactor.battery().capacity()
- batteryLevelRounded = batteryLevel * 100
- batteryLevelRounded = math.floor(batteryLevelRounded)
- if batteryLevelRounded > 90 then
- reactor.setActive(false)
- write("Battery level over 90%, reactor off.\n")
- else
- reactor.setActive(true)
- write("Battery level: " .. batteryLevelRounded .. "%\n")
- end
- sleep(30)
- end
- end
- monitorPower()
Advertisement
Comments
-
- I don't know if this works yet. Will update with a new comment when I verify that it works.
-
- Should be good now! Just use this with a bigger reactor and it'll simply turn it off and on based on it's internal buffer.
Add Comment
Please, Sign In to add comment
Advertisement