How do I go about mouse buttons?

Started by Woten, Wed 17/04/2013 13:45:13

Previous topic - Next topic

Woten

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?

Crimson Wizard

#1
GlobalScript.asc, function on_mouse_click:
Code: ags

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

function on_mouse_click(MouseButton button)
{
  // User clicked right mouse button
  if (button == eMouseRight)
  {
     // Invoke "interact" command
     ProcessClick(mouse.x, mouse.y, eModeInteract);
  }
}

Khris

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.

SMF spam blocked by CleanTalk