Problem with ClaimEvent(); (SOLVED)

Started by TheMagician, Sat 12/03/2005 17:30:39

Previous topic - Next topic

TheMagician

Hi everybody.

My game has a room with an overlay in the top left corner.

If the player clicks on it I want to change to a new room.
Now, because there is no function which handles clicks on overlays I put this code in the "on_mouse_click function" of the room script:

====     ROOM
function on_mouse_click(MouseButton button) {
  if (button == eMouseLeft) {
    if ((mouse.x < 30) && (mouse.y < 30)) {  // mouse is in the upper left corner
      Wait(1);
      ClaimEvent();              // prevent the global script from running
      Wait(1);
      srChangeRainAmount(0);  // some function from the rain plugin
      RemoveOverlay(over1);
      ReleaseCharacterView(EGO);
      NewRoomEx(9,137,145);
      }
  }
}
====

Now here is the problem: if the player clicks on the overlay with the standard Walk cursor ... as soon as the player is in the new room the main character automatically starts moving to the left (towards the coordinates where the player clicked on the overlay).

I thought the ClaimEvent(); doesn't allow my global on_mouse_click to run and therefore the ProcessClick function should not be run -> the character shouldn't move.

====   GLOBAL Script on_mouse_click
[...]
  else if (button==eMouseLeft) {
    if (GetCursorMode()==MODE_LOOK) {
      FaceLocation(GetPlayerCharacter(), mouse.x, mouse.y );
    }
    ProcessClick(mouse.x, mouse.y, GetCursorMode() );
    SetCursorMode(MODE_WALK);
  }
====


Any ideas what I'm doing wrong?
Stefan

strazer

My guess is the ClaimEvent command is invalidated when you change rooms.
You could work around it by setting a global variable/GlobalInt in your first room's on_mouse_click and check it in the on_mouse_click of the new room and running ClaimEvent there.

Pumaman

Ah yes, ClaimEvent doesn't work properly if you change rooms within on_mouse_click/on_Key_press. I'll get it fixed.

TheMagician

Thanks strazer for your suggestion. I'll use it as a temporary workaround.

And thanks of course to Pumaman who is everywhere, sees everything and fixes everything!!!  :)  :)

SMF spam blocked by CleanTalk