MZ How to save custom data in a save file?

Hi there,

I searched a lot for this and always end up on the same threads. I'm pretty sure there was some nice of tutorial or explanation somewhere about this topic, but I can't find it anymore. So if someone can give me a link I would be really happy 😀

The issue is the following: I have a plugin and want to save custom data (an array) to the save file. I was working with "Game_System" and added custom variables to "$gameSystem" and that actually works.
But I also saw an example (this: ) which uses the DataManager. And now I'm not sure which route to go.

The DataManager example also looks a bit nicer but I'm not sure how I could work with this.
Is "Adding variables to $gameSystem" actually the way to go? Is there a good tutorial about that stuff? I just want to follow the best practices 🙂
I don't see any particular reason to mess with the DataManager if all you're doing is adding an array.

Just add a property to any of the saved $game objects and it will be automatically written to save files. Doesn't doing literally nothing look nicer than...that? 😛

I searched a lot for this and always end up on the same threads. I'm pretty sure there was some nice of tutorial or explanation somewhere about this topic, but I can't find it anymore.
I don't think there's any tutorial that's really needed, because it basically consists of one step - create a property of the $gameSystem (or one of the actors or variables or switches or...whatever).

Was that not explained in the threads you said you found? I've seen it come up several times, but...like I said, it didn't seem like there's enough content to make a tutorial about it.

Note: the exception to the above is if you're trying to save some new format of Object - if it doesn't translate to stringify, the default save method won't work on it.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-save-custom-data-in-a-save-file.171491/