Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing the Lua state #62

Closed
UserAB1236872 opened this issue Jan 22, 2018 · 2 comments
Closed

Serializing the Lua state #62

UserAB1236872 opened this issue Jan 22, 2018 · 2 comments

Comments

@UserAB1236872
Copy link

UserAB1236872 commented Jan 22, 2018

At the moment I'm using specs and rlua to write a simple RTS for research-level AI. I won't go into the details, but for various reasons (including tree search, game replays, speculative simulation, and so on) I really need to serialize the entire game state from any frame so that it's arbitrarily rewindable and deterministic on rewind.

At the moment, the lack of serialization is constraining. I basically have to assume the Lua stores no data, and likewise the Rust side must immediately convert any returned Lua data into native Rust types and write it elsewhere. This limits my scripting potential heavily without mucking with the core engine, because I need to essentially implement piecemeal triggers in Rust and use Lua as a simple configuration language (basically just return a table of prebaked entities, triggers and parameters which Rust then executes).

Currently, my strategy is just to serialize the file path of the script, and on startup load it (on rewind I just assume the file is constant).

I'm not asking for full Serde here since I doubt it's even possible (esp. once references get involved), but it would be nice if there was some way to serialize certain data and (pipe dream) Function types, and reattach them to a new context, even if there end up being some constraints. I understand this is likely a Hard Problem™ but I figured I'd file an issue just to see if any partial version of this is even possible.

@jonas-schievink
Copy link
Contributor

There's plenty of serialization libs for Lua that one could draw inspiration from

@jugglerchris
Copy link
Collaborator

Closing as this is an old issue and likely best handled using a Lua serialization library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants