cleanup reactor controller

This commit is contained in:
LordMZTE 2021-11-13 15:43:42 +01:00
parent df0f056360
commit 3e58a0d5b2
1 changed files with 12 additions and 11 deletions

View File

@ -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)