Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Wayne Adams on Sat 21/02/2009 01:40:18

Title: interact on hotspot doesn't work(SOLVED)
Post by: Wayne Adams on Sat 21/02/2009 01:40:18
I have the left mouse button making the dude march around..the right mouse button opens up the hud, the only time the left button does something is when its moused over a hotspot, object, person..etc..

The player can not force interact, the cursor mode and graphic only changes on mouseover..

What works is the mouse cursor changes when mousing over a hotspot.. what doesn't work is when i tell the ANY CLICK script on the mouse over option under the hotspot interaction to do what I tell it (Give a description, change rooms, start a conversation) it does not work..

If more information is nessecary, please make me elaborate.

Thanks.
EDIT: Thanks Trent.
Title: Re: interact on hotspot doesn't work
Post by: Trent R on Sat 21/02/2009 02:29:32
My brain hurts right now, but off the top of my head I'd ask:

-Are you events set up correctly?
-How much have you changed the on_click function in the global script?
-What does your room script look like (functions related to the hotspot, etc)?
-Which version of AGS? 2.72, right?



~Trent
Title: Re: interact on hotspot doesn't work
Post by: Wayne Adams on Sat 21/02/2009 03:31:15
Heres the code for on click:

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
  {
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
    {
    }
  else if (button == eMouseLeft)
  {
    ProcessClick(mouse.x,201, mouse.Mode);
    }
  else // right-click, so cycle cursor
    {   
    if (button == eMouseRight)

gMain_menu_Click(1,4);





    }
  }
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


this is for repeatedly execute:


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
{
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) != hotspot[0]) {
  Mouse.Mode = 2;
} else {
  Mouse.Mode = 0;
}

}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


yes, my version is 2.72

currently in the script for the room, i have an interaction stating if the hotspot is clicked then goto room100
room100 does exist.
I've even gone so far as telling to just display a message if clicked for bug checking..

Title: Re: interact on hotspot doesn't work
Post by: Trent R on Sat 21/02/2009 04:27:41
I'm gonna take a guess and assume that your hotspot is above or below 201 on the y axis. But you're only processing clicks on that single line on the axis.

Try changing your on_click to this:#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft)
  {
    if (mouse.Mode==eModeWalkto) //if Walk mode, walk to where you click
    {
      player.Walk(mouse.x, 201);
    }
    else //otherwise, process the click of whichever mode
    {
      ProcessClick(mouse.x, mouse.y, mouse.Mode);
    }
  }
else // right-click, show HUD
  {  
  if (button == eMouseRight)
    gMain_menu_Click(1,4);
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE



A few other things:
-I changed your tabbing and comments a bit in the on_mouse_click.
-You might want to change the line 'player.Walk(mouse.x, 201);' back to 'ProcessClick(mouse.x, 201, eModeWalkTo);' depending on what advanced scripting you might add later. Changing it will keep some options open for you, and still do the same as player.Walk.
-You can use eModeInteract and eModeWalkTo, instead of '2' and '0' in your rep_exec script.
-The manual entry for ProcessClick links to Hotspot.RunInteraction. Based on what I've seen of your game, both entries might be a good read for you.
-You should upgrade to 3.1.2, unless you have a specific reason to stay with 2.72 (and please don't say the interaction editor, cause your game is already involving enough scripting that the interaction editor will just hold you back IMO)

~Trent