GUI, Inventory & Menu: Difference between revisions
→Checking if the player has a certain Inventory Item
*>Ashen No edit summary |
*>Ashen |
||
Line 182: | Line 182: | ||
Simply use the [http://www.bigbluecup.com/manual/Character.InventoryQuantity.htm InventoryQuantity] property, e.g.: | Simply use the [http://www.bigbluecup.com/manual/Character.InventoryQuantity.htm InventoryQuantity] property, e.g.: | ||
if (player.InventoryQuantity[iKey.ID] == 0) Display("You don't have the key."); | if (player.InventoryQuantity[iKey.ID] == 0) | ||
Display("You don't have the key."); | |||
Or: | Or: | ||
if (player.InventoryQuantity[iStolen.ID] != 0) Display("You can't go in there carrying Stolen goods."); | if (player.InventoryQuantity[iStolen.ID] != 0) | ||
Display("You can't go in there carrying Stolen goods."); | |||
If you want to stop the player from taking an Item multiple times (like taking someting out of a drawer), you're better using a variable. If you use InventoryQuantity and the player can lose the Item later in the game, they'll be able to go back and pick it up again. | If you want to stop the player from taking an Item multiple times (like taking someting out of a drawer), you're better using a variable. If you use InventoryQuantity and the player can lose the Item later in the game, they'll be able to go back and pick it up again. | ||
'''Note:''' | '''Note:''' | ||
* The InventoryQuantity property was introduced in V2.7. Before that, use | * The InventoryQuantity property was introduced in V2.7. Before that, use the ''character[].inv'' array. | ||
[[Category:AGS Beginners' FAQ]] | [[Category:AGS Beginners' FAQ]] |