Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: iamlowlikeyou on Thu 11/11/2010 23:50:05

Title: How to make "any click with no effect, set mode walkto"?
Post by: iamlowlikeyou on Thu 11/11/2010 23:50:05
I want to make it, so that when mouse mode is set to for example look at, whenever mouse clicks anywhere, that doesn't perform a task (i.e. anywhere, that is not a hotspot, a character, an object...),
it changes back to mode walk to.
I take it, that should be fairly easy, but I haven't been able to find the function.

My best guess would be to make a "mouse.IsButtonDown(eMouseLeft)" command and then describe the exceptions, but I don't know how to do that?

Thanks for any help!
Title: Re: How to make "any click with no effect, set mode walkto"?
Post by: Wyz on Fri 12/11/2010 00:01:49
I've slightly altered the default mouse click handler (denoted by white spaces):

function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft)
  {


      Hotspot *hotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
      if (hotspot.ID)
        ProcessClick(mouse.x,mouse.y, mouse.Mode);
      else
        ProcessClick(mouse.x,mouse.y, eModeWalkto);


  }
  else // right-click, so cycle cursor
  {   
    mouse.SelectNextMode();
  }
}
Title: Re: How to make "any click with no effect, set mode walkto"?
Post by: iamlowlikeyou on Fri 12/11/2010 00:07:53
Oooh, right - that's quite clever :)
Thanks!
Title: Re: How to make "any click with no effect, set mode walkto"?
Post by: Khris on Fri 12/11/2010 04:38:43
This will disable almost all interaction clicks on objects and characters.

What you need is
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x,mouse.y, eModeWalkto);
    else ProcessClick(mouse.x,mouse.y, mouse.Mode);
Title: Re: How to make "any click with no effect, set mode walkto"?
Post by: iamlowlikeyou on Fri 12/11/2010 07:16:55
@Khris: Yeah, I spotted that too, however I tried changing it to fit my needs - but this one is even better for this purpose. Thanks!