I have a save data singleton with the following variables
"knight": {
"current": true
}
}
const STARTER_STATS = {
"highscore": 0,
"sword_damage": 0,
"spear_damage": 0,
"anvil_damage": 0,
"fireball_damage": 0,
"axe_damage": 0,
"spiked_armor_damage": 0,
"potions_drank": 0,
"speed_potions_drank": 0,
"strength_potions_drank": 0,
"health_potions_drank": 0
}
var save_data: Dictionary = {
"meta_upgrade_currency": 0,
"meta_upgrades": {
},
"characters": STARTER_CHARACTERS,
"stats": STARTER_STATS
}
var stats:
get:
return save_data['stats']
set(value):
save_data['stats'] = value
whenever I try to increment one of the stats, like this:
SaveData.stats['total_damage_dealt'] += damage
I get the following error:
Invalid set index 'total_damage_dealt' (on base: 'Dictionary') with value of type 'float'
Any ideas why I can't update that stat? I've tried without the custom getter and setter and I get the same error. I can't think of any reason why I shouldn't be able to update that value since it's already initialized.
I'm in v4.2.stable.official [46dc27791]