I have level 0 rusted sword, then I upgrade it and save my game.
I implemented my save system by following Godot tutorials. But with this approach, after exiting and re-launching the game, all rusted swords in the game are now upgraded.
What do I have to do so that only that specific sword is upgraded?
My current system works like this:
detect item on floor:
press key to pick:
check what type of item it is:
check if item slot is viable:
delete item from floor, add into the item slot
And I reverse the order for dropping items, which of course means that item ID changes every time it is dropped and instanced again, so using that is problematic.
func savePlayerData():
var data = {
"strength": strength,}
var dir = Directory.new()
if !dir.dir_exists(SAVE_DIR):
dir.make_dir_recursive(SAVE_DIR)
var file = File.new()
var error = file.open_encrypted_with_pass(save_path, File.WRITE, "P@paB3ar6969")
if error == OK:
file.store_var(data)
file.close()
func loadPlayerData():
var file = File.new()
if file.file_exists(save_path):
var error = file.open_encrypted_with_pass(save_path, File.READ, "P@paB3ar6969")
if error == OK:
var player_data = file.get_var()
file.close()
if "strength" in player_data:
strength = player_data["strength"]