Godot Version
4.2.2
Question
Hello! I’m debugging an issue where my game will periodically fail to read the settings file, so I created a validate_settings()
function:
func validate_settings():
var settings_file = FileAccess.open(settings_path, FileAccess.READ)
var settings_text
if settings_file.get_as_text() == "":
settings_file.close()
return 1
else:
settings_text = settings_file.get_as_text()
var json = JSON.new()
json.parse(settings_text)
settings_file.close()
if json.data == null:
settings_file.close()
return 2
else:
settings_file.close()
return 0
It’s returning 1 every time I try to load the settings into the game when it first loads up. I know the settings_path
variable is set correctly because I’ve referenced that elsewhere in my code and it’s working there. I also verified the text file is in the right encoding. I can’t think of anything else I could be doing wrong.