AGS 2.7PR3: problem with rep_ex_always (SOLVED)

Started by fovmester, Thu 21/04/2005 18:42:50

Previous topic - Next topic

fovmester

I want to have some text showing what's under the mouse cursor. And I want that text to be just below the cursor no matter where the cursor is. So I put the text in a GUI and thought I'd use repeatedly_execute_always to reposition the GUI to the correct position.

The problem is that when some interaction takes place, for example if I click on a hotspot and the character is walking over to that hotspot or he's talking the GUI is not repositioned! It's working fine otherwise (that is when no blocking script is running). What's wrong? I thought that the whole point of repeatedly_execute_ALWAYS was that it would execute ALWAYS!

This is the code I put in my global script:

Code: ags

function repeatedly_execute_always() {
    
  int mx = mouse.x;
  int my = mouse.y;
  int lx = mx;
  int ly = 0;
  
  int width = gLabel.Controls[0].Width;

  // this is to prevent the text from not showing if the cursor is too far to the right.
  if (mx>320-width)
		lx = 320-width;
	
  // this is because I want the text to go up above 
  // the cursor when it's at the bottom of the screen
  if (my > 220) 
		ly = my - 15;
  else ly = my + 10;
  
  gLabel.SetPosition(lx, ly);
}


Can anyone help me?

Pumaman

Try using RefreshMouse, it might be that the mouse x/y isn't updated before rep_exec_always is called.

fovmester

Hey that fixed it! Thanks! :D

But I've got another problem. Now I want the GUI to disappear along with the cursor when something blocking happens. I imported a blank sprite and used that for the Wait-cursor. So the mouse disappears correctly. But how to make the text disappear? I tried to check the mode of the mouse:

if (Mouse.Mode == eModeWait) gLabel.Visible = false
else gLabel.Visible = true;

but Mouse.Mode is never eModeWait even though the mouse definately uses that cursor. So the GUI never disappears. Is this a bug or is there a reason for this?

Pumaman

The cursor mode isn't actually set to Wait, it does a UseModeGraphic(eModeWait) instead.

The easiest way to do what you're wanting is to use  IsInterfaceEnabled

fovmester


SMF spam blocked by CleanTalk