Godot Version
v4.2.stable
Question
I am losing my mind over a dictionary saving issue, which I rebuilt here very simplified:
Code example:
#initiate two different empty dictionaries
var save_data: Dictionary = {}
var game_data: Dictionary = {}func _ready():
#inst. some game data
game_data = {“SomeText”: “Stone”}#save current game data
save_data = game_data#change a variable in game data to simulate game running
game_data[“SomeText”] = “Lava”#print compare values
print(game_data[“SomeText”])
print(save_data[“SomeText”])
Returns:
“Lava”
“Lava”
I absolutely do not understand why the “SomeText” filed in “save_game” also gets changed and would have expected to receive “Lava” “Stone” as outcomes.
I am trying to use this to temporally save a bunch of current game data in “save_game” have to game continuing in “game_data” and be able to jump back to the old data in “save_game”. However, in this example both dictionaries are always 100% the same and do not have any added value
Any hint to what I am missing is highly appreciated!
Best and 1000 thanks
Jokster