lua-users home
lua-l archive

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


I would be very interested in a solution to this as well; my system is fairly 
similar to ER's, with coroutines representing different actions in progress. 
So far, I've more or less abandoned myself to restricting savepoints and 
having complex serialization/deserialization semantics to jump back into the 
middle of a function; a more elegant solution would be great.

Ben

On Tuesday 29 April 2003 01:38 am, Enno Rehling wrote:
> I want to use lua to create a game. NPCs for example will be running lua
> scripts, and events will also be scripted. I'm thinking of implementing the
> scripts as coroutines that yield whenever they've done the amount of work
> they want to do during one frame of the game's engine. That way, I only
> have one lua_State object, and I can call the script engine once per frame,
> and return back to C.
>
> One difficulty I have is that I need to save the current state of the
> scripts when the player is saving the game. Given my current lua_State
> object, I'd like to be able to serialize it to disk together with the rest
> of my savegame data.
>
> Has anyone written something like this before? I've looked through the lua
> code this morning before breakfast - it looks like recreating the state
> object, and registering everything in the right places, is a bit of an
> adventure, and if anyone has gone that way before, I'd like to not reinvent
> that particular wheel :-)
>
> Enno.

-- 
All your people must learn before you can reach for the stars.
		-- Kirk, "The Gamesters of Triskelion", stardate 3259.2