Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: JackAnimated on Fri 08/02/2019 03:21:09

Title: Action when hovering over any object
Post by: JackAnimated on Fri 08/02/2019 03:21:09
I want the mouse cursor to change whenever over any object. Here is the code I have, which lives in Global Script in rep_exec:

Code (ags) Select
Object*o = null;
   
    o = Object.GetAtScreenXY(mouse.x, mouse.y);
    if (o != null)
    { 
    Mouse.UseModeGraphic(2);
    }


Needless to say, it's currently not working.

Thanks.
Title: Re: Action when hovering over any object
Post by: Matti on Fri 08/02/2019 11:06:10
You can only access objects like that in a room's script, not in global. Edit: The problem must be something else.

This should work too btw:

Code (ags) Select
if (GetLocationType(mouse.x, mouse.y) == eLocationObject) Mouse.UseModeGraphic(2);

But, as Danvzare stated in your other thread, you don't need to script anything. Just use the cursor's Animate property.
Title: Re: Action when hovering over any object
Post by: Snarky on Fri 08/02/2019 11:10:10
Quote from: Matti on Fri 08/02/2019 11:06:10
You can only access objects like that in a room's script, not in global.

I don't think that's true. To me it looks like some other bug (maybe the program never reaches this point in the code, for example).
Title: Re: Action when hovering over any object
Post by: Matti on Fri 08/02/2019 11:23:28
You're right Snarky. I just tested it and it worked just fine  ;)