Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: thiezar on Mon 06/12/2010 21:19:05

Title: Get the object at which the mouse is pointing [solved]
Post by: thiezar on Mon 06/12/2010 21:19:05
I need a function that takes as argument the object o hotspot at which the mouse is pointing so i can menage a custom variable i set for that object/hotspot.
For labels it exists @OVERHOTSPOT@ that returns the name of the hotspot the mouse is pointing at. I need the same thing but in a function. How it is done?
Title: Re: Get the object at which the mouse is pointing
Post by: Khris on Mon 06/12/2010 21:25:22
There's GetLocationType(x, y) & [THING].GetAtScreenXY(x, y) which you would usually call like this:

  Hotspot*h;
  Object*o;
  Character*c;

  int mx = mouse.x, my = mouse.y;

  int lt = GetLocationType(mx, my);
  if (lt == eLocationHotspot) {
    h = Hotspot.GetAtScreenXY(mx, my);
    // bad example:
    Display("Mouse is over %s!", h.Name);
  }
  else if (lt == eLocationObject) {
    o = Object.GetAtScreenXY(mx, my);
    ...


Btw, please make sure you exhaust the manual and forum search before opening a thread here.
Title: Re: Get the object at which the mouse is pointing
Post by: thiezar on Mon 06/12/2010 21:44:58
I swear it's been 4 days I'm looking for these functions in the manual but, since I was looking for a specific request, I wasn't able to find them. Same problem with the forum search. I admit i did just a couple of searchings  ::) I'll try to be more scrupolous in future  ;)
I thank you again for your immediate help.
Title: Re: Get the object at which the mouse is pointing [solved]
Post by: Khris on Mon 06/12/2010 23:29:21
You're right, finding a particular command can be hard.
A search for "hotspot under mouse" has this thread as 3rd result though:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40966.0

It's also a good idea to read through the command reference once, to get an idea about how AGS commands are structured and what's possible in general.

Oh and, welcome to the forums :)