Savegame data only mode - coldrockgames/gml-raptor GitHub Wiki

In the Savegame functions you will find two functions, that might look confusing at first glance:

  • savegame_save_struct_async
  • savegame_load_struct_async

Those save a game in "data-only" mode.

So, what does that mean?

While the normal way to save your game is for sure to just persist the current room, so you can restore it later, there are some games, which are mainly data-driven. Where all instances are created dynamically anyways, based on some data files and world maps, things like that.

You can save tons of data and get incredible save/load performance, if you don't persist your objects at all! If your game is designed in such a way, it is enough to store the data of the world, not the world itself.

Those function allow you this. You just send a _data parameter to savegame_save_struct_async and the savegame system will save only this one struct. It may contain anything.
Upon load, your .on_finished callback will receive the loaded data struct as its first argument. You then can start to reconstruct all your object instances manually.

Take Care

While saving/loading a game in data-only mode sounds good, due to its high performance, there's caveat coming with it: Your data struct must not contain any pointers to object instances, because they wouldn't be persisted and as a logical consequence of this, they also can't be restored when the file is loaded. So your savegame might not work. Use this mode only, when you can guarantee, that no instance pointers are involved in the data struct saved.