inventory item stack problem

I am creating the stack system for my inventory, which consists in: if the slot that I dragged has the same item as the slot I am going to drop, check if it is stackable and if so, see if there is space in the inventory to do the stack

I’m doing the following:

if my slot 1 has 4 items and a stack limit of 5 items, has one item left for max stack

then I’m taking the number of items from the slot I’m dragging and adding it to the quantity from the slot I’m going to drop

After that, I am subtracting the sum of these slots with the max stack of the slot that I will drop, which is returning the value in negative, then converting the values ​​to positive with absolute node

this gives me the amount left to fill my max stack in the slot I’m going to drop, I’m taking this value, converting to positive with absolute again and subtracting it from the slot I’m dragging

now that I subtract the value from the slot that I dragged, I am adding it to the slot that I will drop

now I remove this subtracted value from the dragged slot and update the widget

now the problem:

whenever the sum of the slot I’m dragging and the slot I’m dropping is less than the max stack of the slot I’m going to drop, I add the sum of these items to be the new quantity of the slot I’m going to drop, ok, the problem is: As this slot still has space, if I drop this slot on itself, it removes itself, how can I avoid this?

video: 2024-10-30 10-36-08.mkv (19.1 MB)

here the blueprint: stack items posted by anonymous | blueprintUE | PasteBin For Unreal Engine

this simple branch solved my problem, i will left it here in case someone want to do the system as i did