lua-users home
lua-l archive

Re: Switching from lua_pcall to lua_resume to support yield

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Jun 7, 2012 at 4:04 PM, John Dunn <John_Dunn@qscaudio.com> wrote:
> Any other suggestions/comments on what I'm trying to do?
a different idea: keep your current C code and write a 'coroutine
caller' in Lua.
a user could write something like this:
app.add_code (function (api)
 api.move_to (start position)
 local face = 'happy'
 api.draw (face)
 api.wait (60)
 local face = 'wink'
 api.draw (face)
 api.dissolve_to_black()
end)
where add_code creates a coroutine with the given function, and calls
it with an 'api' object that encapsulates a reference to the
coroutine, and methods that manage the spaghetinnes with callbacks
that know the coroutine to resume.
-- 
Javier

AltStyle によって変換されたページ (->オリジナル) /