lua-users home
lua-l archive

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



On Mon, Dec 22, 2008 at 9:47 AM, Alexander Gladysh <agladysh@gmail.com> wrote:
Hi, Duncan!

I'm the other guy behind Lua Alchemy.

Hello! Thank you for your work.
 

> Excellent, thank you. I just did a quick test to see if coroutines work -
> they do - do you know if it would be possible to yield across ActionScript
> "frames", or does the whole script need to be executed within a single one
> currently?

No plans to yield across ActionScript "frames" so far. Suggestions on
the form and on the implementation are welcome.

It is probably too much to ask anyway - ActionScript would need to be fundamentally different internally, I imagine.

What I really would like to be able to try is a program where a hosted Lua script uses coroutines in a simplistic way that demonstrates a Lua function suspending itself until later. For example, this:

  player:say("I shouldn't have eaten that.")
  player:move_to(300,200)
  player:say("I don't feel too good.")
  player:animate("die")

...as a Lua script for some kind of (morbid) Flash adventure game. Each of these methods on the "player" (a Lua object, here, rather than a proxy to an ActionScript object) may internally use coroutine.yield() many times in order to "sleep" until the next step of the game (when the Flash application's timer event next fires).

>> The next version will include syntax sugar so instead of calling
>> as3.call(var, "function", param) you could call var.function(param) and
>> similar calls to make calling ActionScript code look the same as calling Lua
>> code.

> Would it not be var:function(param) in that case? I know it probably doesn't
> actually need it to be a Lua method rather than a normal function call, but
> for consistency's sake.

It would most likely be var:function(param).

Alexander.