Action when hovering over any object

Started by JackAnimated, Fri 08/02/2019 03:21:09

Previous topic - Next topic

JackAnimated

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

Matti

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

Snarky

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

Matti

You're right Snarky. I just tested it and it worked just fine  ;)

SMF spam blocked by CleanTalk