lua-users home
lua-l archive

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


A good idea to implement this would be to use a system sort of like
this:
  actorRunner = coroutine.wrap(actorFunction)
  -- arguments passed inside the actorFunction's yield call
  (yieldedargs ...) = actorRunner(args,....)
.....
  for actor in actors do
    returnVals = actor(arguments...)
  end

Inside the actorFunction, you would want to have some loop that
continually does work, then calls coroutine.yield(args...)
One of the arguments that would be useful to pass into the
actor(..args..) would be an argument to tell the actor to "die",
that is, return out of the function without yielding.

With this, you wouldn't need to setup a new lua state for each
actor, as the coroutine setup would handle state preservation.


As for having the scripts schedule movement or something like that,
I'm not positive as to solutions, but the above should help.
-- 
Thomas Harning Jr.

Attachment: signature.asc
Description: OpenPGP digital signature