Mouse over hotspot 5 & 6 change cursor in all room

Started by Mystère Poe, Sun 10/08/2025 12:12:01

Previous topic - Next topic

Mystère Poe

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.

Mystère Poe

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;
}

Khris

Something like this:

Code: ags
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;
}

Crimson Wizard

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

Mystère Poe

Ok thanks. I'm starting to understand how it works.

SMF spam blocked by CleanTalk