Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: iamlowlikeyou on Tue 18/01/2011 10:44:52

Title: How to check if player is on hotspot? [SOLVED]
Post by: iamlowlikeyou on Tue 18/01/2011 10:44:52
Is there a way to check (supposedly as "function repeatedly_execute_always") if the player is standing on a specific hotspot?
I don't want to do it with regions, because I can max. make 15 regions per room...
Title: Re: How to check if player is on hotspot?
Post by: Unai on Tue 18/01/2011 10:49:49
I'd say that what you need is Hotspot.GetAtScreenXY(int x, int y)

From the AGS Wiki (http://americangirlscouts.org/agswiki/Hotspot_functions_and_properties#Hotspot.GetAtScreenXY):

if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hDoor)
   Display("Mouse on the door");
else if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) != hotspot[0])
   Display("Mouse is on something (but not the door)!");
else
   Display("Mouse not on a hotspot");
Title: Re: How to check if player is on hotspot?
Post by: iamlowlikeyou on Tue 18/01/2011 10:55:39
Okay, so is it reasonable to say:

function repeatedly_execute_always(){ 
 
  if (Hotspot.GetAtScreenXY(player.x, player.y) == hHotspot1){
    Label1.Text = "on hotspot";
  }
 
  else Label1.Text = "not on hotspot";
 
}


...I mean is this a problematic statement in any way?
Title: Re: How to check if player is on hotspot?
Post by: Matti on Tue 18/01/2011 11:42:52
No, that should work nicely.
Title: Re: How to check if player is on hotspot?
Post by: Dualnames on Tue 18/01/2011 19:13:27
I have this feeling that hHotspot1 will give out an error, I may be wrong, but it may. And question; is that repexecalways function in global script? Cause that means it will run in every room. So thing is you're going to need a if player.Room is kind of statement. I haven't tested if hHotspot1 works, I have this feeling it will give out a undefined kind of error, but hotspot
Title: Re: How to check if player is on hotspot? [SOLVED]
Post by: iamlowlikeyou on Tue 18/01/2011 19:42:47
I am putting this in the room script, so it's working :)