Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local lower_thres = 1000000
- local upper_thres = 8000000
- local function check()
- pcall(function()
- for address, componentType in component.list("br_reactor", true) do
- local reactor = component.proxy(address)
- local max = reactor.getFuelAmountMax()
- local energy = reactor.getEnergyStored()
- if energy < lower_thres then
- reactor.setActive(true)
- elseif energy > upper_thres then
- reactor.setActive(false)
- end
- end
- end)
- end
- local timer
- function start()
- if timer then
- event.cancel(timer)
- end
- timer = event.timer(5, check, math.huge)
- end
- function stop()
- if timer then
- event.cancel(timer)
- timer = nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement