Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | TheJollyReaper |
ERROR: File must be opened before use.
At: core/bind/core_bind.cpp:2023
ERROR: parse: Error parsing JSON at line 0:
At: core/bind/core_bind.cpp:3220
ERROR: File must be opened before use.
At: core/bind/core_bind.cpp:2023
ERROR: parse: Error parsing JSON at line 0:
At: core/bind/core_bind.cpp:3220
This is where I assume the problem is, because the only place I deal with files is while saving/loading
# Save Game
func save():
var save = File.new()
save.open("user://%s.json"%player_name, File.WRITE)
var save_dict = {
"player_name":player_name,
"player_health_max":player_health_max,
"player_health":player_health,
"player_attack":player_attack,
"player_defense":player_defense,
"player_speed":player_speed,
"room":room
}
save.store_line(to_json(save_dict))
save.close()
func load(name):
var file = File.new()
file.open("user://%s"%name, File.READ)
var data = file.get_as_text()
var json_result = JSON.parse(data)
var dict = json_result.result
player_health_max = dict["player_health_max"]
player_health = dict["player_health"]
player_attack = dict["player_attack"]
player_defense = dict["player_defense"]
player_speed = dict["player_speed"]
room = dict["room"]
file.close()
goto_scene("res://scenes/dungeon.tscn")
I don’t have any issues testing the game in editor, but once it’s exported (windows desktop) the errors pop up.