ResourceSaver/Loader or FileAccess for game save

Godot Version

4.2.2

Question

Hi guys, for game save should I use resources with ResourceSaver.save() and ResourceLoader.load() or FileAccess for write/read from file? What do you recommend? I say this because it says on the documentation that for loading data, we recommend more ResourceLoader.load() instead of FileAccess: FileAccess — Godot Engine (stable) documentation in English
I am a bit confused on this point

1 Like

If you only want to save resources (Resource / PackedScene) you should use the resourcesaver. If you want to customize your savedata (like custom data-compression or something), you want to use fileaccess. Be careful with resourcesaving though: Savefiles have code in them and it can be executed when loaded in game → if people take save-files from others they might run the risk of running dangerous software. There are tutorials on how to safely-save resources

1 Like

But by “custom data-compression or something” do you mean custom resources?

1 Like

no its more like compressing your data, e.g.: use 16bit for an integer instead of 64bit. its explicit data compression by hand basically.
In general: if you can save it with ResourceSaver → use ResourceSaver. If you dont like the resourceSaver for some reason you use fileaccess

1 Like