Trying to create a contextual cursor, something's wrong.

Started by Darius Poyer, Mon 24/05/2010 19:20:34

Previous topic - Next topic

Darius Poyer

What I'm trying to do is have the cursor mode change depending on what the cursor is currently hovering, so if its a character, then talk to, if there's a hotspot, interact, etc.

To do this I've changed two functions in the global script.

Code: ags

function repeatedly_execute() 
{
  if (Character.GetAtScreenXY(mouse.x, mouse.y)){
    mouse.Mode = eModeTalkto;
    }
  else if (Hotspot.GetAtScreenXY(mouse.x, mouse.y)){
    mouse.Mode = eModeInteract;
    }
  else {
    mouse.Mode = eModeWalkto;
  }
}


function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1)
  {
  }
  else if (button == eMouseLeft) 
  {
    ProcessClick(mouse.x,mouse.y, mouse.Mode);   
  }
  else
  {   
    ProcessClick(mouse.x,mouse.y, eModeLookat);
  }



The right mouse work's perfectly, but when I try to walk with the left mouse button nothing happens (it does dynamically change though).

Khris

I didn't test your code, but I suspect the problem is that Hotspot.GetAtScreenXY(mouse.x, mouse.y) doesn't return null but hotspot[0] over an empty area.
This should be pretty obvious though since the cursor should never change to eModeWalkto.

Anyway, you should use GetLocationType instead.

SMF spam blocked by CleanTalk