I’ve been playing around with ue5 here and there for years and could never really figure things out on my own… well, here I am trying again and I’m trying to add an item to my inventory using maps and was wondering if my logic seems, correct?
No. So what is your inventory map? Looks like string maps to integer?
I doubt you should be “setting” the Map at any point in your function, you should just be adding to it, but it seems very wrong to me.
Do you have an Item class, or at least an item interface you are implementing? Or are all items simply referenced by some integer ID?
In any event, what it looks like you want is, if the item is not there, then add to the map the quantity passed into the function; if the item IS there, then add the quantity to what was already in the inventory.
This works because you cannot add a duplicate key, so Unreal just overwrites it with the new value.
My logic is the result of asking ChatGPT… Unless I miss understood the AI or it’s outdated information. Not really sure but it told me if false drag in a set node.
Well, in programming there is always more than one way to do things. I find ChatGPT gets me 50 to 90% of the way, but is rarely a good solution.
In any event, if you SET the inventory with the inventory, you just get the inventory - it does nothing but waste CPU cycles.
thanks for the help. I appreciate it