If I run 2 or more timers they won’t work. Script example:
function tmr1()
while true do
print(“timer 1”)
wait(50)
end
end
function tmr2()
while true do
print(“timer 2”)
wait(100)
end
end
run(tmr1); run(tmr2)
It’s caused by mistake in register() function in src_lua/scheduling.lua. If there is any timer already registered all others will be given wrong event name in proc array:
local function register (cell, ...)
….
--------------------------------------------------------------------
-- 2 - register timer events
--------------------------------------------------------------------
for _, event in ipairs(events) do
if type(event)=='number' then
local t = internal.set_timer(event)
if not ptwt then -- no timer queue at all
ptwt={ [t] = { cell } }
ptw.timer=ptwt
else -- there is a timer queue...
local evq = ptwt[event] -- should be ptwt[t] ?
if not evq then -- ...but no sub-queue for that timer event
evq = { cell }; ptwt[event] = evq -- should be ptwt[t] ?
else -- there is already a queue for that timer event, append
table.insert(evq, cell)
end
end -- timer events queue
trace("Registered cell for event timer."..t)
end
end
…..
end
Instead of ptwt[event] should be ptwt[t]. Am I right?
I hope it will be fixed soon while there’s no latest Lua version source code available.