Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Technocrat on Thu 18/11/2010 14:30:38

Title: [SORTED] Custom cursor causes MoveCharacterBlocking crash.
Post by: Technocrat on Thu 18/11/2010 14:30:38
I've repurposed the "interact" cursor for my multi-purpose cursor that does everything. Left clicking will walk and interact, and right clicking will look/cancel selected inventory items.

I've only just discovered a problem that it causes - when clicking anywhere in the backdrop of a room where the player is not shown, it crashes, telling me:

Error: MoveCharacterBlocking: character is turned off and cannot be moved.

I can kind of understand *why* it's happening, but I'm not sure what I could do to my cursor script to work around it. It might just be the seizure I've just had addling my brain though.


function on_mouse_click(MouseButton button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
 }
 else if (button == eMouseLeft) {
   //ProcessClick(mouse.x, mouse.y, mouse.Mode );
 if(player.ActiveInventory!=null){ProcessClick(mouse.x, mouse.y, eModeUseinv);return;}
   if(player.Room!=3){     // The main menu. I think this stopped me noticing it originally
   if(Object.GetAtScreenXY(mouse.x, mouse.y)==null && Hotspot.GetAtScreenXY(mouse.x, mouse.y)==hotspot[0] && Character.GetAtScreenXY(mouse.x, mouse.y)==null){player.Walk(mouse.x, mouse.y, eNoBlock, eWalkableAreas);return;}
   }
   ProcessClick(mouse.x, mouse.y, eModeInteract);

 
 }
 else if (button == eMouseRight){
   // right-click our mouse-wheel down, so cycle cursor
       if(player.ActiveInventory!=null){player.ActiveInventory=null;mouse.Mode=2;return;}
       ProcessClick(mouse.x, mouse.y, eModeLookat);
 }

}
Title: Re: Custom cursor causes MoveCharacterBlocking crash.
Post by: Khris on Thu 18/11/2010 15:14:26
Try this:

  else if (button == eMouseLeft) {
    if (player.Room == 3) ProcessClick(mouse.x, mouse.y, eModeInteract);
    else {
      if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeWalkto);
      else {
        if (player.ActiveInventory != null) ProcessClick(mouse.x, mouse.y, eModeUseinv);
        else ProcessClick(mouse.x, mouse.y, eModeInteract);
      }
    }
  }


I didn't really change anything except I used ProcessClick(..., eModeWalkto). You called player.Walk() which will generate the error because the player isn't just invisible, the character is turned off, like the error message says, and thus cannot move.

Your coding style is pretty messy if I may say so so I took the liberty of rearranging things a bit.
Title: Re: Custom cursor causes MoveCharacterBlocking crash.
Post by: Technocrat on Thu 18/11/2010 15:36:09
Wow, thanks for that! Now it works swimmingly.

And yes, it's rather messy! Everything I do tends to be, but I usually pretend it's a style I have!