lua-users home
lua-l archive

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


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.

What I'd like to do is to be able to record the state of
the active lua data/scripts to disk (save-game files) and
restore them again in a later program invokation.

The way I'm using lua entails that it is not just a set of
functions that get invoked for entity-specific events (otherwise
I could just save/restore a list of which scripts had been
loaded), but also that the state of entities (switches on/off,
tracking of AI goals) is also within the lua environment (the
entirety of the game-specific logic is in lua, in theory, and the
C engine API exists to service the scripts rather than vice-

Serializing the globals table is not hard, but a lot of state is
potentially also in closures, etc.  I also wonder where the current
state of yield()ed coroutines may be accessed.

Am I just entering a world of pain?

I can code/design around this in a few not-quite-desirable ways
but I was wondering if anyone else had any insights.

Thanks a lot!
Adam D. Moss   . ,,^^   co:3