On Sat, Feb 14, 2009 at 6:48 PM, Alexander Gladysh
<agladysh@gmail.com> wrote:
Hi, list!
Lua 5.1.4
I need to delay my script execution until I get an event from a host
program. To do this I wrap my script into a coroutine, and pass a code
to resume it into a callback. Engine stores callback in Lua registry
and calls it when ready.
A pseudocode:
local coro -- A forward declaration
coro = coroutine.create(function()
ENGINE.call_me_later(function() assert(coroutine.resume(coro)) end)
coroutine.yield()
end)
assert(coroutine.resume(coro))
When I run it, coroutine.resume() inside the callback fails with
message "cannot resume running coroutine". Coroutine status is
"running" and coroutine.running() points to the coroutine as well.