Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheJBurger on Mon 25/02/2008 19:59:29

Title: character.HasInventoryItem [solved]
Post by: TheJBurger on Mon 25/02/2008 19:59:29
Okay, I feel like I'm doing something stupid, but I can't find a command to the effect of:
character.HasInventoryItem[iItem]

The closest thing I found to this was a command called character.InventoryQuantity, but when I use it, it gives me this error.


if (player.InventoryQuantity[iLockPick] == 1) { // player has the lock pick?
// do stuff
}
else {
  // do other stuff
}

That code doesn't work. It gives the error
Error: Type mismatch: cannot convert 'InventoryItem*' to 'int.'
Is this the right command I'm supposed to be using? If so, how do I fix it?
Title: Re: character.HasInventoryItem ?
Post by: GarageGothic on Mon 25/02/2008 20:04:06
The problem is that you're using an inventory pointer as an index. What you want to do is:

if (player.InventoryQuantity[iLockPick.ID] == 1) { // player has the lock pick?
Title: Re: character.HasInventoryItem ?
Post by: TheJBurger on Mon 25/02/2008 20:41:07
Aha. Fixed now. Thank you.