[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Saving the lua state
- From: "Luc Van den Borre" <luc@...>
- Date: Sat, 29 Jul 2000 21:09:35 +0200
Ales Mlakar wrote:
| I agree that this has nothing to do with Lua, since all saving game stuff
| should be done from the C/C++ side of the game not from Lua. You're using
| Lua just to script things so all acctual variables and stuff is in your C
| code anyway. I don't see why you want to do this in Lua though, really. If
| your C/C++ code architecture is solid, for example derived classes with
| virtual Save & Load functions, this should be a pretty straight foward
| thing. And you don't need to save information about what Lua is doing since
| I think you must do your script functions like Once-per-loop called anyway
| like:
|
| function DoAI(object) -- object is a C++ class
|
| if object->Target
| object->DoWhatYouNeedToDoAndStuff()
| ..and so on
| end;
|
| This really doesnt have anything to do with Lua.
I would disagree with that, but only because you and I seem to have different opinions of what constitutes a script.
In your scheme, Lua scripts can't use any static variables. If that works for your situation, fine, but that's quite a
limit to impose on your script writers.
E.g. you might end up passing a lot of variables to your Lua scripts every time you call them - variables that could be
kept in Lua itself. And you'd need a callback to C every time your scripts need to access a complex data structure.
All the more silly when you see how easy (and elegant) it is to save and restore all variables and data structures in
Lua - a lot easier than from C.
The way I use Lua, the scripts keep all of the state of the game. A hundred or so of these state machines may be running
'at the same time', and I can save all of them with just one function (and to restore them, just execute the save
file!).
In fact, the ease of use of tables, and this state-saving trick are just as important to me as the fact that I don't
need to recompile my app for every little tweak...