aboutsummaryrefslogtreecommitdiff
path: root/advtrains/advtrains_luaautomation/interrupt.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-04-29 19:44:43 +0200
committerorwell96 <mono96.mml@gmail.com>2017-04-29 19:44:43 +0200
commit0c7144bcc49449eba9f6ab8f2c1d8efa72b0307a (patch)
treeeb66e11bc2a6fb1937d85e2006a7f20d39e40e0b /advtrains/advtrains_luaautomation/interrupt.lua
parent331db7ba5f4e4b308c1f8efa93c2b40c5139766d (diff)
parentf42b01c74bdc7e91d3def03125a0e24e6a3bb0d4 (diff)
downloadadvtrains-0c7144bcc49449eba9f6ab8f2c1d8efa72b0307a.tar.gz
advtrains-0c7144bcc49449eba9f6ab8f2c1d8efa72b0307a.tar.bz2
advtrains-0c7144bcc49449eba9f6ab8f2c1d8efa72b0307a.zip
Merge nocrash branch into master and merging it with the unified functions so that restoring works how it should
Also fix minor bugs and an occasional crash with couples
Diffstat (limited to 'advtrains/advtrains_luaautomation/interrupt.lua')
-rw-r--r--advtrains/advtrains_luaautomation/interrupt.lua32
1 files changed, 15 insertions, 17 deletions
diff --git a/advtrains/advtrains_luaautomation/interrupt.lua b/advtrains/advtrains_luaautomation/interrupt.lua
index fa340b8..718b8c7 100644
--- a/advtrains/advtrains_luaautomation/interrupt.lua
+++ b/advtrains/advtrains_luaautomation/interrupt.lua
@@ -22,26 +22,24 @@ function iq.add(t, pos, evtdata)
end
function iq.mainloop(dtime)
- 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
+ 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