lua-users home
lua-l archive

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


"Adam D. Moss" wrote:
> 
> Hi!
> 
> I was wondering if anyone out there has any experience or
> thoughts on serializing and deserializing the state of the
> lua environment to/from disk.
> 
/snip

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." -- 
Daniel Remar.
Björn De Meyer 
bjorn.demeyer@pandora.be