lua-users home
lua-l archive

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

I'm developing a MUD (multi-user dungeon game) as a side project and
I'm going to use Lua for scripting.  You've probably seen my last
e-mail regarding how to share objects but I have that mostly figured
out.  However, I have another question...

Let's say I want to have a script do something like this:   (pseudo-code)

npc = CreateNPC("Bob");
npc:Say("Hello everybody in the room!");

SLEEP(1000);  -- Sleep for one second
npc:Say("Hello again!!");

SLEEP(1000);  -- Sleep for another second
npc:Say("I'm being really annoying now!!");

Now I'm not even sure if SLEEP() is the correct command, but as far as
my host application is concerned if I pause in a Lua script it will
halt the entire program until lua_dofile() returns.

What's the best way to implement the Lua scripting engine into a game?

How can I get Lua to pause (eg. sleep) without stopping my entire game?

Can one Lua instance be shared between shared threads?  (eg. several
players in the game will be executing Lua scripts)

Should I spawn a seperate thread for every single lua script being run?

Any advice would be greatly appriciated!!