Godot Version
4.2.1.stable
Question
Hi! I would like to ask for how exactely do I code loading simple settings. This is the code for saving audio (it’s on a scene):
func _on_save_pressed():
var file = FileAccess.open("user://settings.data", FileAccess.WRITE)
var settings = {}
settings["master_volume"] = AudioServer.get_bus_index("Master")
file.store_var(settings)
file.close()
and this is the code for loading (it’s on autoload):
func _ready():
if FileAccess.file_exists("user://settings.data"):
var file = FileAccess.open("user://settings.data", FileAccess.READ)
var settings = file.get_var()
settings["master_volume"] = AudioServer.get_bus_index("Master")
file.close()
The debugging tool say everything is ok. When I load it doesn’t load the settings, even though the file exists. I suspect it’s loading but not actually setting anything. How should I proceeed? Thanks!