lua-users home
lua-l archive

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


Nathaniel Lewis <linux.robotdude@gmail.com> writes:

> I am currently writing a game engine for Linux that I intend to open
> source.  I realize that I need some sort of script to go along with a
> map in it to describe what will happen when.  I decided to turn to Lua
> as a script because its syntax is simple and not too difficult to
> learn.  But I need the interpreter to run as a separate thread than
> the main thread for reasons like this:
>
>     while encounter_Living("DemoEncounter") > 0 do
>      -- Do something while the encounter is alive --
>     end
>     ui_Print("Encounter Killed");

I don't see what makes this require a separate thread rather than a
coroutine.  It would not appear that there are _asynchronous_ events
changing something from living to dead, so it should be perfectly fine
to let the killing routine be responsible for waking the above loop.

> Currently all I have been able to do is have an update function called
> after every frame is rendered but and waiting would cause the game to
> lock up.  Is there any way to run the Lua interpreter as a separate
> thread from the main thread for Windows and Unix?

Not clear yet why you would want to do that.

-- 
David Kastrup