Optimize electric network operations a little

This commit is contained in:
2025-01-08 22:45:12 +01:00
parent 6e2a3c22cf
commit 752fe4f192
5 changed files with 47 additions and 10 deletions

View File

@@ -60,6 +60,18 @@ function industrialtest.Machine.updateFormspec(self,pos)
meta:set_string("formspec",self:getFormspec(pos))
end
function industrialtest.Machine.canUpdate(self,pos)
return false
end
function industrialtest.Machine.triggerIfNeeded(self,pos)
local timer=minetest.get_node_timer(pos)
if not timer:is_started() and self:canUpdate(pos) then
minetest.debug("updating "..minetest.serialize(pos))
timer:start(industrialtest.updateDelay)
end
end
function industrialtest.Machine.onTimer(self,pos,elapsed)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()