Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Wed 16/11/2005 12:43:01

Title: Problem with "Interact Inventory Item"
Post by: on Wed 16/11/2005 12:43:01
Hi,

I have a suitcase in my inventory which I'd like to open upon "Interact Inventory Item". The problem is that nothing I put under "Interact Inventory Item" will be executed. When you click on the inventory item with the interact cursor active the cursor changes to the image of the inventory item, which is OK for most of the inventory items but for the suitcase I'd like to change this default behaviour. How can I do that?

Thanks for helping,
PennyLane
Title: Re: Problem with "Interact Inventory Item"
Post by: petazzo on Wed 16/11/2005 13:03:18
Use Talk to and not Interact with the item.
Title: Re: Problem with "Interact Inventory Item"
Post by: Ashen on Wed 16/11/2005 13:17:09
To explain: the default AGS behaviour is that using eModeInteract on Inventory items sets them as active inventory, and there's no simple way to get round this - other than using a different cursor mode, as petazzo suggests.

However, if you do that, remember that you'll need to set all the other items to become active inventory when you 'Talk to' them. The easiest way would be using unhandled_event, e.g.:


function unhandled_event(int what, int type) {
  if (what == 5 && type == 2) { //'Talk to' inventory
    player.ActiveInventory = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  }
}


Rather than manually adding the command to every item's 'Talk to inventory item' interaction. (Or whatever mode you choose to use.)


You could also use the 'Handle inventory clicks in script' option, but that's a lot more work, for the same result.

Title: Re: Problem with "Interact Inventory Item"
Post by: on Thu 17/11/2005 19:11:26
Thanks for your help. Meanwhile we have found another very inelegant yet effective solution  ;D

PennyLane