- Edited
Hi,
I'm using the following code to transfer data between 2 dictionaries.
func _on_hire_pressed():
if PlayerWealth.totalcost <= PlayerWealth.coin:
for i in range(0, 5):
var checkbox = get_node("VBoxContainer/Raster/RecruitList/CheckBox" + str(i))
if checkbox.is_pressed():
var heroData = HeroesData.generated_heroes[int(i)] # Accessing the corresponding hero data
HeroesData.heroes.append(heroData) # Transferring data to heroes dictionary
HeroesData.generated_heroes.erase(heroData)
PlayerWealth.coin -= PlayerWealth.totalcost
PlayerWealth.totalcost = 0
buynow.emit()
self.queue_free()
else:
warning.text = "[center]insufficient funds![/center]"
I think the problem i'm having is that by erasing the data i'm changing the index value of the remaining data.
could anyone tell me a way to fix this?