cleanup reactor controller
This commit is contained in:
parent
df0f056360
commit
3e58a0d5b2
|
@ -4,18 +4,19 @@ if reac == nil then
|
||||||
error "no reactor found!"
|
error "no reactor found!"
|
||||||
end
|
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
|
while true do
|
||||||
local cap = reac.getEnergyCapacity()
|
if reac.mbIsAssembled() then
|
||||||
|
update()
|
||||||
-- 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
|
Loading…
Reference in a new issue