lua-users home
lua-l archive

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

>From  Fri Jul 21 19:11:33 2000
>From: Falko Poiker <>
>We're currently implementing the save game for the game we're developing
>that uses lua, but I've run into the problem of saving the lua state.  The
>lua state has quite a few pointers and such, so I imagine saving it may be
>alot of work.  Has anybody done this yet?  I understand MDK 2 saves their
>games as lua files - anybody know how this works?

There are two differents issues in "saving a state".

First, there is the simpler form of merely saving the information required to
resume a game, say, the rooms that were visited, points and bonus, this
kind of stuff. This is all very simple and can be saved as a Lua program
that mere assigns the required values to global variables or to a table
that is returned by the chunk or something.
Once this file is saved, the game can be resumed by simply loading the
program again, doing whatever initializations are needed (eg. registering C
functions and such) and then loading the Lua file that was previously saved.
For this simpler form, lua/test/save.lua can help.
Lua has been designed for this kind of stuff, in fact.

Second, there is the harder form of saving *everything* in the innards of Lua,
including all strings and where Lua as executing and such.
This is much harder and I doubt that it's what is needed.
But perhaps I'm missing something here.