I'm new to saving and loading games. I struggled to follow the documentation for a bit before I found a video that seemed to to work fine.
The project saves and loads as intended in the editor, but not after exporting. I made sure to export the *json as a resource, but I probably failed to set up the save data correctly in the first place.
Can somebody help me find out what I'm doing wrong?
const SaveFile = "user://save_file.save"
var data = {}
func _ready():
load_data()
func save_data():
var file = File.new()
file.open(SaveFile, file.WRITE)
file.store_var(data)
file.close()
func load_data():
var file = File.new()
if not file.file_exists(SaveFile):
data = {
"LevelNum" : 0,
"SpawnList" : []
}
save_data()
file.open(SaveFile, File.READ)
data = file.get_var()
file.close()
func reset_data():
data = {
"LevelNum" : 0,
"SpawnList" : []
}
save_data()