Map var gets overwritten with Add

Hi,

When adding to a Map var made of a data asset and text it overwrites the last entry added to the Map so it’s basically only storing the latest one. I’m really not sure what’s going on as I have a similar setup with my inventory and that works fine, don’t know what I’m missing here.

What order of key & values are you using

a) data asset (key) => string (value)
b) string (key) => data asset (value)

The key needs to be unique to be able to store a value.
Perphaps your data asset needs to have the equals operator overridden to identify what makes it unique (if it is the key).

Map vars get overriden with the most recent value so as an example if I understand you correctly

1 A
2 B
3 C

If you add
3 A

It becomes

1 A
2 B
3 A

I am doing it like this

image

basically I am trying to add different ammo sizes. The Override Name will have Pistol Ammo (Small), Pistol Ammo (Medium) etc. I guess as you say the problem is the data asset being the same; Pistol Ammo.

Yeah it depends on how they are mapped if you are doing

Pistol Ammo - Small
Pistol Ammo - Large

Then what is happening is the first variable is being overriden you’d be better off having something mapped like

1 - Pistol Ammo (Small)
2 - Pistol Ammo (Large)

This way it doesn’t get overriden then when you need to use it you can use a string compare or something similar

1 Like

ah thankyou, it makes sense now. I managed to sort it with this

image

1 Like

Yep there ya go!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.