I’ve made an inventory system and I’m trying to make a check of when the inventory is full, so I can inform the player. So I have an integer that starts at 1 because the player is starting with one item, then it’s incremented by 1 after an item is added. I set the number of slots to 2 just for testing purposes.
Anyway, with the code below the branch should hit false after 1 item is added and I pick up a new item, then print out “Inventory full” but for some reason it doesn’t. I’ve even added a print node that shows me “NumberOfItems” is 2. 2 is not less than 2. Therefore the condition “Is number of items less than number of slots” should be false, or did I do something wrong here?
I’ve also tried with lastindex +1 but it didn’t work.
if this inventory is an array instead of relying on a separate “number of items” variable you can use the Array.Length() having a “max items/slots” is still good. there might also be the ability to “stack items” which this will help with as well because increasing the stack size should not increase the “number of items”.
I would suggest not incrementing your Number of Items until after it is actually added (you could get false increases), but Array.Length() can clean this up as well.
for the problem at hand:
put print strings after each of your branches to track each step of your logic.
you could also put a break point on that first branch after your Interact() and step through watching Number of Items as it is changing.
I solved it and it was really simple. Since I have stackable items I tracked the number of added items in the AddItems function instead. Then I called that variable when doing the check and it reaches the false node.