Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: SilverSpook on Wed 18/11/2015 20:52:33

Title: Event When Attempting To Use Item
Post by: SilverSpook on Wed 18/11/2015 20:52:33
Is there a way to have a certain script happen whenever you attempt to use a certain item on anything?  For example, the player has a lighter and if they try to use it without any fuel inside I want a message to say, "I can't use this till I find some fuel." 

I see you can set in the events properties "Use inventory on this item", but that only works when another inventory item is used on it.  Is there somewhere you can make an event like, "This item used on anything" sort of function?

Thanks!
Title: Re: Event When Attempting To Use Item
Post by: Grok on Wed 18/11/2015 21:18:22
This aught to do the trick


function on_mouse_click(MouseButton button)
{
  if(cPerson.ActiveInventory==iLighter)
    {
      Display("I can't use this till I find some fuel.");
    }
}
Title: Re: Event When Attempting To Use Item
Post by: SilverSpook on Wed 18/11/2015 21:21:46
Thanks Grok!