lua-users home
lua-l archive

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


Hey,
 
I am at exactly the same juncture. To my knowledge there is no experience on this list with saving Lua states. It is possible but a bit of a brute force approach. Basically, the state is just a collection of C structures and, as such, can be saved and restored. I have a hunch it would be hard to get it right, making the code pretty high maintanance. Serializing game object state tables is what I am considering/prototyping at the moment. We don't go dumping raw process memory heaps when saving games written in C, do we? Instead we rely on that the OS will load the executable and we only need to serialize the application state variables. Same line of reasoning may be applied to Lua if you think of Lua VM as a process. Restoring the instruction pointers? Well, same thing, how would you go about this for an application written in C? There is a difference between restoring the game state and the process state.
 
Alex.
 
-----Original Message-----
From: Krzysztof Jakubowski [mailto:kjakubowski@city-interactive.com]
Sent: Thursday, May 06, 2004 9:07 AM
To: lua@bazar2.conectiva.com.br
Subject: lua state

Hi,
I am new here. I need to serialize lua_state. I was searching mailing archives, but all posts were about serializing tables, globals, etc. There is also lua_dump or luaU_dump, but it doesn't solve my problem becouse I need to save "current instruction pointer".
 
I would like to break execution of script (using lua_yield), save the whole state and exit the game. Later I would like to load the state and resume (lua_resume) the execution of script. Is is possible?
 
Is there an explanation of lua_State structure, somewhere?
 
Thanks