hi guys.. this is my autoload code for save/load of some settings for characters. as you can see it is a simple one, the problem is when i set the name or color, i see changes in game, but nothing changes in config file. so when i restart the game, it return to its default value, how can i change values/name in config file that when i restart the game i see the effects in the game not just the default values? thank you :)

extends Node

const SAVE_PATH = "res://settings.cfg"
var config_file = ConfigFile.new()
var stored_info = {"color": {"body_color1": Color(1,1,1,1), "body_color2": Color(0,0,0,1)}
                   ,"player_info":{"player_name": "Some Dude"}}

func _ready():
     save_settings()
     load_settings()

func save_settings():
     for section in stored_info.keys():
         for key in stored_info[section].keys():
             config_file.set_value(section, key, stored_info[section][key])
     config_file.save(SAVE_PATH)

func load_settings():
     var error = config_file.load(SAVE_PATH)
     if error != OK:
        print("Failed Loading Settings File. error code %s" % error)
        return[]
     for section in stored_info.keys():
         for key in stored_info[section].keys():
             stored_info[section][key] = config_file.get_value(section, key, null)
             print("%s: %s" % [key, section])
     return[]

func get_setting(category, key):
	return stored_info[category][key]

func set_setting(category, key, value):
	stored_info[category][key] = value

for ex. i use

get_node("/root/global").set_setting("color", "body_color1", Color(0,1,0,1))

for changing character's skin to green and it works in game, but nothing changes in config file

At first glance, I would say the reason it is not saving the changed settings is because you are calling save_settings and then load_settings in _ready. I would suggest flipping it around, so that save_settings is called after load_settings. That is what I would change if I was trying to solve the problem (though as I said, I only glanced through the code).

Also, if you are not already, you'll want to have some way to trigger saving the settings before the game is closed if you want settings that have changed while the game is running to be saved. If you do not have anything in place, an easy way to test the functionality is to add save_settings to the end of the set_settings function, though you'll eventually want to use a more performant, permanent solution later down the line as calling save_settings every time a setting is saved could be costly to performance.

Hopefully this helps :smile: