Change mouse cursor at specific coordinates [SOLVED]

Started by iamlowlikeyou, Sat 06/11/2010 23:23:52

Previous topic - Next topic

iamlowlikeyou

I have tried using this:

Quote

There's an outstanding request on the tracker for an automatic cursor change but it has not been implemented yet.
And you can't currently get the position of the room edges (tracker entry), let alone check if crossing them would lead to another room.

For now, you would have to do everything manually, for example:

Code:

// room script

#define EDGE_RIGHT 300;


Code:

// script for room: Repeatedly execute

 if (GetViewportX() + mouse.x >= EDGE_RIGHT) { // if mouse over right edge
   mouse.UseModeGraphic(eModeArrowRight); // eModeArrowRight is a custom cursor you have to create in the editor
 }
 else mouse.UseDefaultGraphic(); // if not over right edge, revert current mode to its default graphic


You will have to tweak things depending on what control interface you're using (MI-style, Sierra-style etc.).


My room code looks like this:

Code: ags

#define RIGHT_EDGE 316

function repeatedly_execute(){
  if (GetViewportX() + mouse.x >= EDGE_RIGHT){
    mouse.UseModeGraphic(eModeRight);
  }
  else{
    mouse.UseDefaultGraphic();
  }
}


However it's not working. Can anyone tell why?
Thanks for your help.

monkey0506

#1
In one place you're saying "RIGHT_EDGE" and in the other you're saying "EDGE_RIGHT". Is that copy/paste fail?

Also, please elaborate as to what you mean when you say "it's not working". We need to know exactly what's happening in order to really be able to tell you why. By saying it's not working you could mean that you want something entirely different to be happening than what this code would do (if it were properly written). If you don't tell us what it's doing and what you want it to do, then we're left to guess what you're trying to achieve, and any answers you get may therefore be incorrect. :-\

iamlowlikeyou

Quote from: monkey_05_06 on Sat 06/11/2010 23:35:34
In one place you're saying "RIGHT_EDGE" and in the other you're saying "EDGE_RIGHT". Is that copy/paste fail?

Also, please elaborate as to what you mean when you say "it's not working". We need to know exactly what's happening in order to really be able to tell you why. By saying it's not working you could mean that you want something entirely different to be happening than what this code would do (if it were properly written). If you don't tell us what it's doing and what you want it to do, then we're left to guess what you're trying to achieve, and any answers you get may therefore be incorrect. :-\

Sorry.
Yes, that was a copy paste fail.

I have written the code as it should be in my room.
And by "not working", I mean it doesn't perform anything - when I move the mouse to the specific coordinates, nothing happens.

monkey0506

Did you write that repeatedly_execute function yourself? I just realized that you said this is in the room script. Note that rooms handle repeatedly execute differently. The GlobalScript and any scripts you create yourself you can just add repeatedly_execute and it will be automatically called. This is not true for room scripts.

Room scripts have to have a repeatedly execute function linked through the room's events pane (the lightning bolt icon). By default this function is called "room_RepExec" not repeatedly_execute. You can name the function repeatedly_execute if you want, but you would have to manually type (or copy/paste) the function name into the appropriate textbox for the event.

So, in short, the reason it's not doing anything is because the code is in fact never getting called.

iamlowlikeyou

Quote from: monkey_05_06 on Sun 07/11/2010 00:30:25
Did you write that repeatedly_execute function yourself? I just realized that you said this is in the room script. Note that rooms handle repeatedly execute differently. The GlobalScript and any scripts you create yourself you can just add repeatedly_execute and it will be automatically called. This is not true for room scripts.

Room scripts have to have a repeatedly execute function linked through the room's events pane (the lightning bolt icon). By default this function is called "room_RepExec" not repeatedly_execute. You can name the function repeatedly_execute if you want, but you would have to manually type (or copy/paste) the function name into the appropriate textbox for the event.

So, in short, the reason it's not doing anything is because the code is in fact never getting called.

I didn't know - that fixed it!
Thanks a lot :D

monkey0506

This is actually something that I view as somewhat of an artifact of older versions of AGS, predating the 3.0 Editor. Prior to that we had the Interaction Editor and the only way to create a repeatedly execute function for rooms was through it.

However, I'd say that at this point it probably wouldn't hurt to try and phase that event out in favor of just using the standard repeatedly_execute function as is available to every other script. Could just be me though. :P

Glad you got it fixed.

Ryan Timothy B

Yep, I've already mentioned how that is a serious confusion many moons ago.
It definitely should be phased out.

SMF spam blocked by CleanTalk