Saving Settings, nonexistent section (File:ini)

Question

So i have my Setting Saving function, is works wonderfully und i can see the ini Data on my PC and read it. Godot gets an Error that the section" audio" is no find. But i can the section in the ini file

the Error:
@load_audio_settings(): Cannnot get keys from nonexistents Section


var config = ConfigFile.new()
const SETTINGS_FILE_PATH = "user://settings.ini"


func _ready():
	if not FileAccess.file_exists(SETTINGS_FILE_PATH):
		config.set_value("video", "fullscreen" , true)
		
		
		config.set_value("audio", "music_volume", 1.0)
		config.set_value("audio", "sfx_volume", 1.0)
		
		config.set_value("language", "game_language", "English")
		
		config.save(SETTINGS_FILE_PATH)
	else:
		config.load(SETTINGS_FILE_PATH)


func save_video_setting(key:String, value):
	config.set_value("video", key, value)
	config.save(SETTINGS_FILE_PATH)

func load_video_setting():
	var video_settings ={}
	for key in config.get_section_keys("video"):
		video_settings[key] = config.get_value("video", key)
	return video_settings


func save_audio_setting(key:String,value):
	config.set_value("audio", key, value)
	config.save(SETTINGS_FILE_PATH)


func load_audio_settings():
	var audio_settings = {}
	for key in config.get_section_keys("audio"):
		audio_settings[key] = config.get_value("audio", key)


func save_language_setting(key:String, value):
	config.set_value("language", key, value)
	config.save(SETTINGS_FILE_PATH)

func load_language_settings():
	var language_settings = {}
	for key in config.get_section_keys("language"):
		language_settings[key] = config.get_value("language", key)
	

And the Code in the Settings Menu to preload the current Settings


func preload_settings():
	var audio_settings = ConfigFileHandler.load_audio_settings()
	music_slider.value = min(audio_settings.music_volume, 1.0)
	sfx_slider.value = min(audio_settings.sfx_volume, 1.0)


	var video_settings = ConfigFileHandler.load_video_setting()
	fullscreen_check_box.button_pressed = video_settings.fullscreen

Screenshot 2024-07-14 143615

i got it
Soo in Project_Settings: Autoload:

My C_FileManager was bellower then the setting_Menu_Autoload. So i trys first to read the Settting.ini before is load and opened in the C_File Manager

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.