![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Noddy |
I’ve been trying to save settings to a config file, but keep failing. I have some code and I don’t know whats wrong with it. Here it is:
extends Node2D
const SAVE_PATH = "res://settings.cfg"
var mouseSensitivty = 3/10
var _config_file = ConfigFile.new()
var _settings = {
"Video": {
"FullScreenMode": ProjectSettings.get(size/fullscreen),
"SRX": ProjectSettings.get(size/width),
"SRY": ProjectSettings.get(size/height),
"VSYNC": ProjectSettings.get(vsync/use_vsync)
},
"Game": {
"FOV": get_fov(),
"Sensitivty": mouseSensitivty
}
}
func _ready():
pass
func save_settings():
for section in _settings.keys():
for key in _settings[section].keys():
_config_file.set_value(section, key, _settings[section][key])
_config_file.save(SAVE_PATH)
I need some things explained as I don’t understand what went wrong and why. The whole computer froze when I tried to run this script. I didn’t use autoload. I used a Node2D with a script attached. The script is also incomplete but gave no errors in the editor.