How to check if player is on hotspot? [SOLVED]

Started by iamlowlikeyou, Tue 18/01/2011 10:44:52

Previous topic - Next topic

iamlowlikeyou

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...

Unai

I'd say that what you need is Hotspot.GetAtScreenXY(int x, int y)

From the AGS Wiki:
Code: ags

 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");
I am a deeply superficial person

iamlowlikeyou

Okay, so is it reasonable to say:
Code: ags

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?

Matti


Dualnames

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
  • works.

    Code: ags
    
    function repeatedly_execute_always(){  
      
    if (player.Room==1) { 
     if (Hotspot.GetAtScreenXY(player.x, player.y) == hotspot[1]){
        Label1.Text = "on hotspot";
     }
    }  
      else Label1.Text = "not on hotspot";
      
    }
    
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

iamlowlikeyou

I am putting this in the room script, so it's working :)

SMF spam blocked by CleanTalk