Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mystère Poe on Sun 10/08/2025 12:12:01

Title: Mouse over hotspot 5 & 6 change cursor in all room
Post by: Mystère Poe on Sun 10/08/2025 12:12:01
Hello :) I have another question.
Is it possible to use the global script to change the cursor mode (cursor image) on all hotspots 5 and 6 in the game? I'd like this to apply automatically to all rooms where I draw a hotspot 5 or 6.
Title: Re: Mouse over hotspot 5 & 6 change cursor in all room
Post by: Mystère Poe on Sun 10/08/2025 23:51:25
It works perfectly in a room but I don't know how to apply it to all hotspots 5 & 6 in the game.



function hHotspot6_MouseMove(Hotspot *theHotspot)
{
    Mouse.SaveCursorUntilItLeaves();
    Mouse.Mode = eModeCursD;
}

function hHotspot5_MouseMove(Hotspot *theHotspot)
{
    Mouse.SaveCursorUntilItLeaves();
    Mouse.Mode = eModeCursbas;
}
Title: Re: Mouse over hotspot 5 & 6 change cursor in all room
Post by: Khris on Mon 11/08/2025 14:41:56
Something like this:

int prevHotspotId;

function repeatedly_execute() {
  Hotspot* h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  int currHotspotId = h.ID;
 
  if (currHotspotId == 5 && prevHotspotId != 5) {
    Mouse.SaveCursorUntilItLeaves();
    Mouse.Mode = eModeCursD;
  }
  if (currHotspotId == 6 && prevHotspotId != 6) {
    Mouse.SaveCursorUntilItLeaves();
    Mouse.Mode = eModeCursbas;
  }

  prevHotspotId = currHotspotId;
}
Title: Re: Mouse over hotspot 5 & 6 change cursor in all room
Post by: Crimson Wizard on Mon 11/08/2025 14:45:40
I also recommend looking into Custom Properties that let add values to hotspots and other things. This is often better than relying on hotspot/object's number:

https://adventuregamestudio.github.io/ags-manual/CustomProperties.html
Title: Re: Mouse over hotspot 5 & 6 change cursor in all room
Post by: Mystère Poe on Mon 11/08/2025 20:28:03
Ok thanks. I'm starting to understand how it works.