[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Multiple Scripts, Pausing, Threads, and Persistant Variables
- From: "Sean Middleditch" <sean.middleditch@...>
- Date: Mon, 20 Mar 2000 10:07:56 -0500
I'm new to Lua, and have a quick question (ok, a few...): Is it possible to
load a precompiled script, and then only run a PORTION of that script, halt,
run some other code, then return where I left off?
Basically, I'm making a game that will start multiple scripts and have them
run. However, some of these scripts may do things like say they're going to
wait for this or that to happen... I could have the wait functions call the
game loop (what I'm looking into doing right now), but I'd rather that the
game loop control the scripts, not the scripts control the game loop.
Basically, what I'm looking for is a way to say, "OK, here is this instance
of this script... it has called the wait_for_whatever function, which set a
'pause' flag or somesuch, so the call to run the script returns and the C++
program continues to execute. The next game loop iteration, it looks at
it's currently running scripts, and tells them to continue. The 'paused'
script re-enters the function that caused it to pause. The function does it
checks, realizes the event has occured, and unsets the 'pause' attribute, so
the script continues its execution."
Another question is does Lua have "persistant" global varibales? Can I, for
example, have a `do_file ("scripta.lua");' in my C++ code, have that script
set variable pglobal to 25, and on another call to `do_file
("scripta.lua");' or a call to `do_file ("scriptb.lua");' have pglobal still
defined with a value of 25? If not, I'll just implement it through C
extensions... ;-)
Also, is Lua thread safe? I recall seeing a version specifically made for
threads; is it compatible with other Lua add-ons like the socket add-on? My
game will be a MUD, and there may be several servers running at once to deal
with large player loads, and the servers will need to cooperate properly.
Sorry for the near incoherant babbling, I'm not all that great at explaining
things... :)
Thanks,
Sean Middleditch