How can I distinguish 2 items that use the same row in a data table

Hi all, How can I distinguish 2 items that use the same row in a data table?
I have an inventory system where I can pick up items, but when I pick up the same weapon twice, how can I distinguish them? They are the same BP
image

I do have an array index (The print string at the end), maybe someone knows how to do it with that?
Thanks help is appreciated

Hey there @Faze_Kaas! The answer is somewhat dependent on your inventory system. Most developers have an itemID or some other form of metadata applied to the item itself and where it’s stored.

Hi, I use an ItemID, but that is set to the row name

image


It works but when you have the same weapon twice I dont know it treats them both as 1, is there a better/other way to set the ItemID?

Oh I think I see what may be happening. Are you using a data table as the inventory or just as an Item database? Wherever you’re storing your item specific data like durability, modifiers, etc is where you would also handle the item instance’s data. Looks like your inventory itself is running off of an array likely, and that’s referencing the DataTable right? When you pull out an item it’s just reading from the data table and not looking at anything else?

Yes my inventory is an array, but its a reference to a structure not data table

I followed this tutorial episode 1-6 so far.

Its the first time I am making an inventory so I dont know much about this yet

No worries! Just asking enough questions to see how you handled it to make my recommendations without being as general.

So your item struct, you should have whatever metadata in the object included in that. When you open the item, you could be applying the data of it to that struct to the item info from the data table and that is what constitutes your item right?

If I understood you correctly, yes.

But I think I have made it already,


I added a new variable for the instance in the inventorystruct


Based on which Item I pickup I set a variable that adds +1 everytime.


Then I assign that variable to the ItemIDInstance in the Inventorystruct

If you dont mind me asking what did you mean with metadata?

Is that the variables for each row nam/ItemID?

Thanks for your time and help

Basically when I reference metadata it’s just basically variables in whatever struct you have for the items that describe the item. Say, for a picture, metadata are the little tags like when it was taken, when the file was last used, camera type etc. For reference with items it’s just different pieces of information that let’s you identify what item it is, what it does, durability, buffs, whatever. I noticed you marked it as resolved, did you get it?

Sorry for the late answer, yes I got the solution.
Thanks for explaining!

1 Like