Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactor = peripheral.wrap("back")
- -- Max level is fixed for all reactor sizes?
- local reactorMaxEnergyCapacity = 10000000
- local reactorStoredEnergy = 0
- local reactorStoredEnergyPercentage = 0
- while true do
- -- Get the amount of RF stored in the reactor
- reactorStoredEnergy = reactor.getEnergyStored()
- reactorStoredEnergyPercentage = (reactorStoredEnergy/reactorMaxEnergyCapacity)*100
- print("Energy level at: " .. reactorStoredEnergy .. " (" .. reactorStoredEnergyPercentage .. ")")
- -- If the reactor is active AND % of stored energy is 99 or above
- if reactor.getActive() and reactorStoredEnergyPercentage >= 99 then
- -- turn off the reactor
- print("Turning reactor off")
- reactor.setActive(false)
- elseif not reactor.getActive() and reactorStoredEnergyPercentage < 99 then
- -- otherwise IF the reactor is not active AND stored RF below 99%
- -- tur it on
- print("Turning reactor on")
- reactor.setActive(true)
- end
- -- Sleep for aproximately 20 ticks so we don't
- -- Overload the server unnecessarily
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment