lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] wrote:
> Here is a very high-level overview of what we do in our game

Thanks its great help for newbie.

> - Scripts get periodic messages from the engine when interesting
> things happen (collision, timer goes off, pushed, etc)

Does the periodic message mean just like a callback:

   -- Some LSO
   function onCollision()
      -- do sometihng

or is it some bigger mechanism I am miss.

> - Scripts also can assign themselves a "state" function, which can run
> blocking code. If this state function calls Yield(), it stops

I imagine coroutines is one possible way.  I worry other project people do not like to rely on cooperation multitasking or to worry they take too much time.  So my prefered proach is to have an interpreter in one thread and from another thread to message them (a) please yield if you can or (b) please yield no matter what.  And if they do not respond to make the interpreter stop.

To force the interpreter to stop I think I can use the lua_sethook() functionality.  But, I like to have the chance to pass message into one interpreter from C and for some other Lua interpreter.  Any idea? 

> This is plenty of flexibility for our needs. We have quite a big game
> -- hundreds and hundreds of script classes; the total LOC probably
> exceeds that of the main engine :-)

And how can you debug problemed lua scripts?

Sign-up for Ads Free at