Hello everybody! I have made an inventory system with item count and item count limit.
My problem is that is the max item count is 3 and I have 2 in the inventory, when I add 5 of the item; the thing that happen is:
slot 1 will be 3.
slot 2 will have 1.
it does not add the right amount of the item.
Inventory code:
Inside the code I call the script again but with the new count:
Item_Pickup(argument0,last_count);
the script don't loop itself enough times to give the right amount of the item.
My problem is that is the max item count is 3 and I have 2 in the inventory, when I add 5 of the item; the thing that happen is:
slot 1 will be 3.
slot 2 will have 1.
it does not add the right amount of the item.
Inventory code:
Code:
if (global.inventory[i] = argument0) //Check if item exists in slot
{
max_stack = Item_Max_Stock(argument0);
if (max_stack > global.item_count[i]) //Check for item limit
{
if (max_stack < global.item_count[i]+argument1) //If the count + pickup count is bigger then max
{
last_count = abs(max_stack-global.item_count[i]);
global.item_count[i] = max_stack; //Set the count to max
Item_Pickup(argument0,last_count);
return(1);
}
else //If the count + pickup count is lower then max
{
global.item_count[i] += argument1; //Add to count
return(1);
}
}
}
Item_Pickup(argument0,last_count);
the script don't loop itself enough times to give the right amount of the item.