@Megalomaniak said:
Whats in PlayerData.gd at & around line 263 and in SaveManager.gd at & around line 22?
PlayerData's pack()
function adds all the PlayerData variables to a dictionary (the data variable) which I then send to the SaveManager's save()
function (SaveManager is an autoload with name Save
). In PlayerData around line 263 is:
Save.save("PlayerData", data)
var load_data = Save.load("PlayerData")
print (load_data.equipped_amulet.item_name)
At the moment I'm saving and then directly loading for debugging.
var load_data = Save.load("PlayerData")
is line 263
The SaveManager:
var save_data = SaveResource.new()
func save(context : String, data : Dictionary):
save_data.version = ProjectSettings.get_setting("application/config/version")
save_data.data[context] = data
var error : int = ResourceSaver.save("user://save_game.tres", save_data)
if error != OK:
push_error("There was an error when saving: %s" % error)
print("SAVED")
func load(context : String):
var load_data := ResourceLoader.load("user://save_game.tres", "", true)
print ("LOADED")
print(load_data.data[context].equipped_items_inventory)
return load_data.data[context]
var load_data := ResourceLoader.load("user://save_game.tres", "", true)
is the SaveManager's line 22
And the SaveResource:
extends Resource
class_name SaveResource
export var version : String
export var data : Dictionary
In the example from PlayerData, the last print should give me the name of the equipped amulet but the Resources that gets loaded back is empty.