here I am getting the item index, the problem is: if I have 2 identical items in 2 different slots, I will receive the same index for both
This is happening considering that I’m looking for items with the same id, but that’s not what I’m looking for, I want to get the index of each item even though they are the same, how should I do?
The search result should be an array of int that you fill if the items match.
I’ll assume that the search is currently in a function, and you call Return Node after the first match - now you only need to do this at the end of the slot array. You need to make a local array variable and return that.
Here’s how I’m doing it, I want as soon as the item is added to my equipment array, it takes the index of that item and passes it to my slot, would the id check really be necessary in this case?
each slot has a fixed index, whenever I remove the item from the array, the item that was index 1 will become index 0, but in my slot it will still be index 1, how can I update the index whenever you remove an item?
Hi,
for a fixed inventory.an easier way is that not to add items to the array.you could pre-define the array length.
and give every widget slots an index manually.
when dropping on the slot,you can get the index in the slot and use that index to modify the array in player.
same for removing,just set an array member to empty using index from widget slot.
I did this, now this is what happens: I programmed it so that if the slot is empty, I can’t drag it, if I don’t put any item it works, but if I put an item, remove that item, I can drag the slot even without content inside
I’m not sure if that’s the problem in this case, but using Text as an ID is not the best idea. If I remember correctly (from personal experiments), in PIE the comparison is done character by character, but when running Standalone (and in a packed project) the comparison is done by TextID (if localization of this text is enabled, as in your case). And the problem (feature) is that it is unique for each text. Therefore, when comparing you will get “false” in almost all cases, even for two visually identical texts.
this is the debug time.you can print it out to see if the the text is empty.
if it’s not empty means that the issue might be in the removing process.
If it’s empty means the engine has problems comparing text like @PREDALIEN mentioned.(I’m not sure this too)
so you can compare something else like string,name,integer,etc.
for some reason, whenever I placed an item in the slot, even after removing it, it always returned that the slot was no longer empty, the solution I found was to create a function in the component to check if the slot had something based on the index