0 votes

I'm building out a menu system (Godot 3) that uses a different scene for each menu screen. Currently I have one scene for Audio settings and another for Video settings. What would be the best way to save game settings to a file (and possibly any documentation on it)?

I've tried using a config file save, but if I change a Video setting, it rewrites the entire file, in effect removing any Audio settings I changed. The same is true visa versa. I then started working on a json file save, but I think the same is true, though haven't gotten it to work 100%.

I'm trying to come up with creative ways to still use a config file (spent too long figuring out its implementation), but I welcome any hints on handling this more effectively.

in Engine by (43 points)

An alternative solution that I haven't tested: put everything on one scene with a scroll bar or something, and, upon scene close, gather all the values and save them to the file. While I haven't tested this, I think this would also work for if the game crashes on the scene, since nothing would be saved until the "end" of the scene.

Would still be good to know if there is a good solution to my original question.

1 Answer

+1 vote

My global (autoload) class holds all my settings. They are loaded from one or more config files at startup. There's a method in there to write all the settings to a file. My various scenes that have settings in them call the global class's save method to save all settings.

There's really no other way to do it unless you want one file per type of settings. Settings tend to be global anyway so it's not bad to load them up in the autoload. You can make a class that does it or have a bunch of hashes...the key is just to load them all in one place and save them all in one place.

by (141 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.