Fix redstone doing infinite loops

master
Novatux 2013-05-29 18:14:17 +02:00
parent 42af0a9398
commit 461ba1253a
1 changed files with 11 additions and 2 deletions

View File

@ -11,14 +11,23 @@ end
local tick = 0
TICKS = 10
local copy = function(tbl)
tbl2 = {}
for key,val in pairs(tbl) do
tbl2[key] = val
end
return tbl2
end
minetest.register_globalstep(function(dtime)
tick = tick + 1
if tick >= TICKS then
tick = 0
for _, t in ipairs(timer) do
local tm = copy(timer)
timer = {length=0}
for _, t in ipairs(tm) do
t.f(unpack(t.args))
end
timer = {length=0}
end
end)