• Advertisement
Sign in to follow this  

Deserializing Lua coroutines with Pluto

This topic is 3405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement