diff options
Diffstat (limited to 'advtrains/advtrains_luaautomation/interrupt.lua')
-rw-r--r-- | advtrains/advtrains_luaautomation/interrupt.lua | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/advtrains/advtrains_luaautomation/interrupt.lua b/advtrains/advtrains_luaautomation/interrupt.lua index b8fc879..718b8c7 100644 --- a/advtrains/advtrains_luaautomation/interrupt.lua +++ b/advtrains/advtrains_luaautomation/interrupt.lua @@ -21,30 +21,25 @@ function iq.add(t, pos, evtdata) run=true end -minetest.register_globalstep(function(dtime) -return advtrains.pcall(function() - - if run then - timer=timer + math.min(dtime, 0.2) - for i=1,#queue do - local qe=queue[i] - if not qe then - table.remove(queue, i) - i=i-1 - elseif timer>qe.t then - local pos, evtdata=queue[i].p, queue[i].e - local node=advtrains.ndb.get_node(pos) - local ndef=minetest.registered_nodes[node.name] - if ndef and ndef.luaautomation and ndef.luaautomation.fire_event then - ndef.luaautomation.fire_event(pos, evtdata) - end - table.remove(queue, i) - i=i-1 +function iq.mainloop(dtime) + timer=timer + math.min(dtime, 0.2) + for i=1,#queue do + local qe=queue[i] + if not qe then + table.remove(queue, i) + i=i-1 + elseif timer>qe.t then + local pos, evtdata=queue[i].p, queue[i].e + local node=advtrains.ndb.get_node(pos) + local ndef=minetest.registered_nodes[node.name] + if ndef and ndef.luaautomation and ndef.luaautomation.fire_event then + ndef.luaautomation.fire_event(pos, evtdata) end + table.remove(queue, i) + i=i-1 end end -end) -end) +end |