Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ------ on Wed 26/10/2011 23:16:11

Title: ------
Post by: ------ on Wed 26/10/2011 23:16:11
------
Title: Re: Only one inventory item for a object
Post by: Khris on Wed 26/10/2011 23:23:06
Say your inventory item is called iYellowStone.
You can do this:
  if (player.InventoryQuantity[iYellowStone.ID] == 0) player.AddInventory(iYellowStone);

Since this is a bit technical, a new function was added some time ago: Character.HasInventory.
  if (!player.HasInventory(iYellowStone)) player.AddInventory(iYellowStone);
Title: -------
Post by: ------ on Wed 26/10/2011 23:58:53
---------
Title: Re: Only one inventory item for a object (SOLVED)
Post by: Khris on Thu 27/10/2011 00:45:04
I just noticed you can also do this:

  player.InventoryQuantity[iYellowStone.ID] = 1;

The only difference is that setting it directly won't trigger the "inventory was added" event, but I figure you won't need it here anyway, if you're even using it.