lua-users home
lua-l archive

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


I'm still not following how this works with my code. Cooroutines seem to execute within a single script if I read it correctly. A yield will return control to a central loop also within the script. At what point does my code start executing again so I actually do all my 'game' code?

For example, when I call lua_dofile it blocks until execution has completed(as far as I know). So when I'm say loading a level from my code what I'm looking at doing architecturally is loading a lua file that places all the entities(models etc) and sets up the mission loop, periodically the main mission loop would need to check on a mission completion status.

This is all fine so far but with a blocking lua_dofile the mission thread will never return. My game graphics rendering\input\sound etc will never take place. Is there a Yield() command in Lua that return from lua_dofile? Then in my games main loop I can call some kind of lua_dofileResume() to resume the scripts activity?

Right now the only (ugly) way I can see this would work would be to have a lua script that call my rendering engine to draw the graphics and do physics \ gather input etc. 

Am I missing the whole point here? I found this C command 'lua_newthread'. Why does this exist for? I can imagine that this might do half my job in starting a blocking script in a thread but I'm not sure if this is the intended use...

Many thanks for your patience,

Chris


<Snippety Bits>
> From: Nick Trout [mailto:nick@rockstarvancouver.com]
> Subject: RE: Game Integration
> I've been writing a Lua tutorial and there is a page on coroutines:
> http://lua-users.org/wiki/CoroutinesTutorial
> 
> Regards,
> Nick


NOTICE
This e-mail and any attachments are confidential and may contain copyright material of Macquarie Bank or third parties. If you are not the intended recipient of this email you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. Macquarie Bank does not guarantee the integrity of any emails or any attached files. The views or opinions expressed are the author's own and may not reflect the views or opinions of Macquarie Bank.