Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PERXEO on Thu 20/04/2023 22:20:32

Title: exclusive inventory item for interact with an hotspot (SOLVED)
Post by: PERXEO on Thu 20/04/2023 22:20:32
What is the way to indicate which is the exclusive inventory object with which we want to interact so that it is the only one possible and any other interaction is interpreted as invalid and is not detected by the function hotspot.IsInteractionAvailable(mouse.Mode)
(https://www.flowingbytes.com/ags/inventoryonHotspot.jpg)

In other words:
1) If I use the correct inventory item with an hotspot i want to run the correct action with isInteractionAvailable
2) If i don't use the correct inventory item with an hotspot i want to run a personal unhandled event to manage it.
 
Title: Re: exclusive inventory item for interact with an hotspot
Post by: Khris on Thu 20/04/2023 22:54:13
If you assign a function to that event, IsInteractionAvailable(eModeUseinv) will be true.

In your handler function you need to check player.ActiveInventory and call your custom function in the else clause (you have to make it global for that, i.e. import it in the global header).

function hGriffoBarra_Useinv() {
  if (player.ActiveInventory == iExclusiveItem) {
    // ...
  }
  else MyUnhandled();
}
Title: Re: exclusive inventory item for interact with an hotspot
Post by: PERXEO on Fri 21/04/2023 07:14:24
thanks!!! I supose that it's not managed with the unhandled_event native of Ags, it isn't?
Title: Re: exclusive inventory item for interact with an hotspot
Post by: Khris on Fri 21/04/2023 07:59:04
No, the automatic calling of unhandled_event only happens if there's no function linked to the event.
Title: Re: exclusive inventory item for interact with an hotspot
Post by: PERXEO on Fri 21/04/2023 10:18:51
Thanks!! SOLVED with capitals!!