I researched this code and find a question that is the addtimer's sending script-wait.timer_resume has no argument,but the function definition has argument like this:
function timer_resume (name)
if the timer trigger the script(wait.timer_resume),How could the function(timer_resume) recongnize the argument and find the thread which stored in table(threads)?
-------------------------------------------------------------
function timer_resume (name)
if the timer trigger the script(wait.timer_resume),How could the function(timer_resume) recongnize the argument and find the thread which stored in table(threads)?
-------------------------------------------------------------
function timer_resume (name)
local thread = threads [name]
if thread then
threads [name] = nil
local ok, err = coroutine.resume (thread)
if not ok then
ColourNote ("deeppink", "black", "Error raised in timer function (in wait module).")
ColourNote ("darkorange", "black", debug.traceback (thread))
error (err)
end -- if
end -- if
end -- function timer_resume
function time (seconds)
local id = "wait_timer_" .. GetUniqueNumber ()
threads [id] = assert (coroutine.running (), "Must be in coroutine")
local hours, minutes, seconds = convert_seconds (seconds)
check (AddTimer (id, hours, minutes, seconds, "",
bit.bor (timer_flag.Enabled,
timer_flag.OneShot,
timer_flag.Temporary,
timer_flag.ActiveWhenClosed,
timer_flag.Replace),
"wait.timer_resume"))
return coroutine.yield ()
end -- function time