Get the object at which the mouse is pointing [solved]

Started by thiezar, Mon 06/12/2010 21:19:05

Previous topic - Next topic

thiezar

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?

Khris

There's GetLocationType(x, y) & [THING].GetAtScreenXY(x, y) which you would usually call like this:

Code: ags
  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.

thiezar

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.

Khris

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 :)

SMF spam blocked by CleanTalk