[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: SV: Serializing lua state.
- From: "Brian A. Knudsen" <brian@...>
- Date: Wed, 11 Sep 2002 20:35:35 +0200
The "Script.cpp" C++ class wrapper has something like it built-in, but
it ignores userdata ..
[mailto:email@example.com] På vegne af Björn De Meyer
Sendt: 11. september 2002 19:33
Til: Multiple recipients of list
Emne: Re: Serializing lua state.
"Adam D. Moss" wrote:
> I was wondering if anyone out there has any experience or thoughts on
> serializing and deserializing the state of the lua environment to/from
Well, that is not that difficult in lua. Check the
test/save.lua script of the lua-5.0-alpha source distrubution.
Basically, you use a for loop to walk over all Lua tables
that contain the variables you want to serialise, and use format()
to output that data to a file in lua format. To load your
file, simply use dofile() or such to re-import the data.
If cheating is an issue, then you might want to compile
the lua output file to bytecode, or compress it with zlib,
or cloak it by using some kind of roman cipher. Or,
use checksums or such. However, then, your procedure
to load the game will be a bit more difficult, though.
"No one knows true heroes, for they speak not of their greatness." --
Björn De Meyer