Godot Version
v4.7.2.stable.official
Question
When saving files, everything seems to work correctly. When loading files, the loaded information seems to be ignored in favor of the current game state. For example: 1) data is incremented to 10, 2) data is saved, 3) data is incremented again to 20, 4) data is loaded and overwrites active game state, 5) data still shows 20, not 10. What could be causing this?
“All” extends resource. It includes several sub-resources. This script simply saves the state to a default file path. By viewing “user://save00.tres” I can confirm that the file is being saved correctly. I think the problem must be with the way file is being loaded. Am I not properly overwriting the current state? Is there some way to clear cached data?
extends Node
@onready var state := All.new()
var defaultSavePath := "user://save00.tres"
func saveGame():
state.take_over_path(defaultSavePath)
ResourceSaver.save( state, defaultSavePath)
func loadGame():
var newState = ResourceLoader.load( defaultSavePath )
newState.take_over_path(defaultSavePath)
state = null
state = newState
for item in state.characters:
print( item.identity.familyName )