Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Akumayo on Wed 22/03/2006 22:14:38

Title: Problem with calling inventory ID (SOLVED)
Post by: Akumayo on Wed 22/03/2006 22:14:38
I have the following if statement:

if (inventory[player.ActiveInventory].ID == GetGameParameter(GP_NUMINVITEMS,0,0,0)) {


However, even though I've called for the item's ID number, I still get the error:
Quote
Type mismatch: cannot convert 'Inventory Item*' to 'int'

Is inventory[player.ActiveInventory].ID not an int?
Title: Re: Problem with calling inventory ID
Post by: monkey0506 on Wed 22/03/2006 22:20:29
Hmmm...you appear to be a bit confused about the way things work.

player.ActiveInventory is an InventoryItem* (pointer-to-InventoryItem), not an integer.  To get the integer value of this item, you can just type player.ActiveInventory.ID.

You could type inventory[player.ActiveInventory.ID].ID but that's pointlessly redundant.

So, replace that line of code with:

if (player.ActiveInventory.ID == GetGameParameter(GP_NUMINVITEMS,0,0,0)) {
Title: Re: Problem with calling inventory ID
Post by: Akumayo on Wed 22/03/2006 23:01:31
Ahh, thank you.  That was the problem.