Re: [GD-General] Re: [mlist] RE: Off the shelf scripting languages
Brought to you by:
vexxed72
From: Thatcher U. <tu...@tu...> - 2003-04-28 15:10:01
|
On Apr 28, 2003 at 02:35 +0200, Enno Rehling wrote: > Thatcher Ulrich wrote: > > >On Apr 23, 2003 at 12:05 +0300, Ivan-Assen Ivanov wrote: > > > > >In general, the Lua stack will be chock full of pointers to live > >objects, as will the Lua objects on the heap. So as Tom says, you > >serialize this just like you serialize anything else -- traverse the > >live objects, keep track of object ID's, fix up pointers, etc. > > I've just started looking at lua and whether that would be a good > replacement for our own scripting. I started by looking at coroutines and a > simple scheduler and ran across the same issue of serializing the state for > savegames. Are there any good examples on how to traverse the lua stack and > find my C pointers to do the serialization? I'd be thankful for a few > pointers :-) That in particular should be pretty straightforward; just iterate over the stack elements (using the Lua API) and look for entries which are userdata. But, besides your own data, there are various parts of the VM that need to be serialized as well, not to mention Lua's heap objects, which may also reference your objects. The Lua garbage-collector code (src/lgc.c) is very similar to what you need for serialization. I think the lua-l mailing list would be a better place to ask, though. -- Thatcher Ulrich http://tulrich.com |