cleanup reactor controller
This commit is contained in:
parent
df0f056360
commit
3e58a0d5b2
|
@ -4,18 +4,19 @@ if reac == nil then
|
|||
error "no reactor found!"
|
||||
end
|
||||
|
||||
local function update()
|
||||
local newstate = reac.getEnergyStored() < reac.getEnergyCapacity() * 0.8
|
||||
|
||||
local active = reac.getActive()
|
||||
|
||||
if newstate ~= active then
|
||||
reac.setActive(newstate)
|
||||
end
|
||||
end
|
||||
|
||||
while true do
|
||||
local cap = reac.getEnergyCapacity()
|
||||
|
||||
-- this happens when the chunk loads in for some reason. gotta check to prevent crash
|
||||
if type(cap) == "number" then
|
||||
local newstate = reac.getEnergyStored() < cap * 0.8
|
||||
|
||||
local active = reac.getActive()
|
||||
|
||||
if newstate ~= active then
|
||||
reac.setActive(newstate)
|
||||
end
|
||||
if reac.mbIsAssembled() then
|
||||
update()
|
||||
end
|
||||
|
||||
sleep(5)
|
||||
|
|
Loading…
Reference in a new issue