Sign in to follow this  
eriatarka

Deserializing Lua coroutines with Pluto

Recommended Posts

I've just looked at Pluto a bit, and it seems to be a very nice solution for serializing game state to a file. There's one point I don't understand about it though. The documentation says that Pluto can serialize coroutines. If I create a coroutine from C via lua_newthread(), it returns a pointer to a lua_State which represents the new coroutine's call stack, as I understand it. So if I serialize the coroutine and then deserialize it again, how do I recover this lua_State pointer so that I may resume the coroutine from C? I'm thankful for any hints; I think the author of Pluto is on this forum, so I hoped there'd be a good chance to get an answer.

Share this post


Link to post
Share on other sites
You'll have to the use Lua registry to keep a referable tag for the cororotine around I suspect, of just give it a global tag if you don't mind having the rest of Lua know about the coroutine.

-ddn

Share this post


Link to post
Share on other sites
Quote:
Original post by ddn3
You'll have to the use Lua registry to keep a referable tag for the cororotine around I suspect, of just give it a global tag if you don't mind having the rest of Lua know about the coroutine.

-ddn


I understand that, yes, and that takes care of tracking the Lua-side part of the coroutine. But how do I get the lua_State pointer back which I originally obtain when calling lua_newthread()? I can hardly store that in the Lua registry since it's a C pointer which will no longer be valid after deserialization.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this