Godot Version
4.3
Question
I’m setting up a save system for my game which worked fine (Based on Godotneers tutorial on youtube)
I initially had a basic array for my “upgrades” which held all relevant info that required saving, however as the number of upgrades grew, I wanted to categorize them and separate them for easier management during development.
To do this I set up a Dictionary of arrays for each category of upgrades.
What I’m struggling with is saving this dictionary for loading later on.
I currently do this :
func on_save_game(saved_data_upgrades:Dictionary):
for group_name in upgrades_dict.keys():
saved_data_upgrades[group_name] = []
var upgrades_in_group = upgrades_dict[group_name]
print("Check1")
for upgrade in upgrades_in_group:
var upgrade_data = UpgradeData.new()
upgrade_data.title = upgrade.title
print("Check2")
upgrade_data.unlocked = upgrade.unlocked
upgrade_data.bought = upgrade.bought
saved_data_upgrades[group_name].append(upgrade_data)
Using this code I do reach the check1, but never the check2, most of my arrays are sill empty as I haven’t sorted the upgrades yet, but the arrays that shouldn’t be empty appear blank on my save file (.tres file). The dictionnary keys however do appear
What am I doing wrong ? And if there are better ways to do this I’m all ears!
EDIT: bad coding on my part in my loading logic, fixed