- Home /
Inventory system Stacking an item problem
How do i stack item that will put the item into other inventory slot if the max stack count of it reached the Maximum Stack count
if (GUI.Button (new Rect (40, 400, 100, 40), "Add 1 Potion"))
{
AddPotion (2);
}
void AddPotion(int id)//With stacking the currentStack count is being added to all of the items of the same id, and more items still fill the inv.
{
for (int i = 0; i < inventory.Count; i++) {
if (inventory [i].itemID == id && inventory [i].itemCurrentStack < inventory [i].itemMaxStack)
{//Stacking
inventory [i].itemCurrentStack ++;
break;
}
else if (inventory [i].itemName == null)
{
for (int d = 0; d < database.items.Count; d++)
{
if (database.items [d].itemID == 2)
{
inventory [i] = database.items [d];
inventory [i].itemCurrentStack = 0;
break;
}
}
break;
}
}
}
What's wrong with your code? Do you have a problem with it?
Yes. i want to make that when The CurrentStack of potion is 10. The Potion will get full of stacks and cant get another item.
When i add a potion, it will add 1 to the CurrentStack. But when the Currentstack is equal to the Item$$anonymous$$axStack i want to make the Add potion button will do nothing when the Current stack is equal of the Item$$anonymous$$axStack.
Yes, I want that if my $$anonymous$$ax Stack count is = 10, the other potion that i get will go to other slot and make another stack of 10.
Your answer
Follow this Question
Related Questions
Issues with Inventory script 0 Answers
Inventory armor wielding proplem,How to convert from derived to base 1 Answer
Inventory loop bolt 0 Answers
Inventory List Crafting HELP 0 Answers
C# Inventory System: Modify a targeted character's stats 1 Answer