Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Zoolander on Thu 06/04/2006 04:22:52

Title: Action occurs if certain item in inventory (SOLVED)
Post by: Zoolander on Thu 06/04/2006 04:22:52
Hi everyone.  I'm sure this is possible, I just can't find it in the manual.  How is it done so that an action will take place only if a certain item is in inventory? 

For example, if an NPC asked if I had a coin.  If the coin was in the inventory, the player character would say yes, otherwise the answer is no.
Title: Re: Action occurs if certain item in inventory
Post by: Vince Twelve on Thu 06/04/2006 04:49:13
QuoteInventoryQuantity property
(Formerly known as character[].inv, which is now obsolete)

int Character.InventoryQuantity[]

Gets/sets the quantity of the specified inventory item that the character currently has. The array index is the inventory item number, from the Inventory pane in the editor.
Usually, you should use the AddInventory and LoseInventory functions to modify the character's inventory; however, if you need to add or remove a large number of items in one go, directly changing this array can be an easier method.

If you change this array directly, the on-screen inventory will not be updated. In this case, you must call UpdateInventory to see any new or removed items.

Example:

Display("The player has $%d.", player.InventoryQuantity[iCash.ID]);

will display how many inventory items of type iCash the player has.
See Also: UpdateInventory, Character.AddInventory, Character.LoseInventory


Something like:


if(player.InventoryQuantity[iSomething.ID]>0){
  //do something
}
Title: Re: Action occurs if certain item in inventory
Post by: Zoolander on Thu 06/04/2006 05:22:44
Good, that worked!  Thanks very much!