Problem with calling inventory ID (SOLVED)

Started by Akumayo, Wed 22/03/2006 22:14:38

Previous topic - Next topic

Akumayo

I have the following if statement:
Code: ags

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?
"Power is not a means - it is an end."

monkey0506

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:

Code: ags
if (player.ActiveInventory.ID == GetGameParameter(GP_NUMINVITEMS,0,0,0)) {

Akumayo

Ahh, thank you.  That was the problem.
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk