Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Woten on Wed 17/04/2013 13:45:13

Title: How do I go about mouse buttons?
Post by: Woten on Wed 17/04/2013 13:45:13
Hello.

I wanted to make it so every time the player right click's he "Uses" the corresponding thing. How do I go about that?
Title: Re: How do I go about mouse buttons?
Post by: Crimson Wizard on Wed 17/04/2013 15:24:26
GlobalScript.asc, function on_mouse_click:
Code (ags) Select

function on_mouse_click(MouseButton button)
{
  // User clicked right mouse button
  if (button == eMouseRight)
  {
     // If user has inventory item selected...
     if (player.ActiveInventory != null)
     {
        // Invoke "using inventory" command
        ProcessClick(mouse.x, mouse.y, eModeUseinv);
     }
  }
}


About ProcessClick: http://www.adventuregamestudio.co.uk/wiki/Game_/_Global_functions#ProcessClick

EDIT: lol I misread what you said.
You probably meant "Interact" action, in which case:
Code (ags) Select

function on_mouse_click(MouseButton button)
{
  // User clicked right mouse button
  if (button == eMouseRight)
  {
     // Invoke "interact" command
     ProcessClick(mouse.x, mouse.y, eModeInteract);
  }
}
Title: Re: How do I go about mouse buttons?
Post by: Khris on Wed 17/04/2013 15:37:58
Woten, you're using the 9-Verb GUI, correct? (This is something you need to mention when asking a question like that.)

The GUI supports default actions, for instance opening/closing doors, or talking to characters when right-clicking them. Afaik you can set the default action by naming the object something like "door>o". This will set the default action to "open". Refer to the documentation of the 9-Verb GUI for how to use this.