mouse.Mode detection on characters/hotspots

Started by Creedy, Fri 06/08/2010 18:58:42

Previous topic - Next topic

Creedy

Hi guys,

I've got a problem with the mouse.Mode property. I have several custom mousemodes (eModeThink, eModeMental etc.).

When using them with inventory items over the "OtherClick()" function, I have no problems at all:

Code: ags

function iApple_OtherClick()
{
  
  if (mouse.Mode == eModeThink) {
    player.Say("Hm, I think it's an apple.");
  }
  else if (mouse.Mode == eModeMental) {
    player.Say("Doesn't work at all.");  
  } 
}


But when using the same code with characters and hotspot and "AnyClick()", nothing happens:

Code: ags

function cAmy_AnyClick()
{
  if (mouse.Mode == eModeThink) {
    player.Say("It works"); //DOESN'T WORK!
  }  
}


I tried to replace eModeThink with the Mode-ID (10 in this case), but it doesn't work either.

They are all new custom mousemodes, starting with ID 8 (so I haven't overwrite the standard mousemodes look, interact etc.)


Can you help me out? Reasons? Workarounds? Solutions?

Thanks very much!

Khris

The first thing to do in a situation like this is adding a debug line:

Code: ags
function cAmy_AnyClick()
{
  Display("%d", mouse.Mode);

  if (mouse.Mode == eModeThink) {
    player.Say("It works"); //DOESN'T WORK!
  }  
}


This will show whether the function is called at all and also display the mode ID.

I tried what you did myself and got a reaction immediately.
Did you link the function properly? Does it say "cAmy_AnyClick" in the event field?

Creedy

In fact, I tried some debugging lines before.
The strange thing is a different behaviour for Inventory items, Hotspots and characters. The functions are called, because I receive feedback, but wrong ones.

Code: ags

function cAmy_AnyClick()
{
  Display("%d", mouse.Mode); // Delivers: "0" which is not correct
}

function iVCard_OtherClick()
{
  Display("%d", mouse.Mode); // Delivers: "8" which IS correct
}

function hCorner_AnyClick()
{
  Display("%d", mouse.Mode); // Delivers: "0" which is not correct
}


The custom cursors start with IDs "8", "9", "10" etc. and I switch them over a custom GUI with the ClickAction property set to "SetCursorMode" and NewModeNumer set to "8".

I'm really confused about this  ???

Creedy

Just solved it....well, partially.

The reason was this:

Code: ags

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 );
    mouse.Mode = eModeWalkto;
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
    // mouse.SelectNextMode();
  }
}


The mousemode gets set back to eModeWalkto (ID 0), before the Any_Click function is called.

SMF spam blocked by CleanTalk