Resetting cursor mode and action label after carrying out function

Started by tor.brandt, Sun 06/11/2016 01:43:40

Previous topic - Next topic

tor.brandt

I'd like to make it so that the mouse cursor mode and my action label text are reset after carrying out a function.

By "after carrying out a function" I mean e.g. if I have selected a "look at" mode and then clicked on e.g. a hotspot, e.g. making the player say something (that's the function), then the resetting should occur after the player has finished talking (i.e. after the entire function has been carried out).

And by "reset" I mean that the cursor mode should switch back to "walk to", which is my default mode, and the action label text should be set to "".
I know how to use mouse.Mode == eMode..., and .Text = "", but what I don't know is what these commands should be functions of.

I tried making them functions of on_mouse_click(), but that seemed to make a mess somehow - and besides I'm not sure if the resetting would actually occur before or after the additional functions of the given click.

I use five modes beside "walk to", namely "look at", "use", "pick up", "talk to", and "use inv", and the resetting should occur after carrying out functions of them all. Also, if any mode beside "walk to" is selected, and I click on eLocationNothing (except for inv items!), then the resetting should occur as well.

Cassiebsg

Create a function called "ResetMouse" or something like that. add the lines to reset it the emousemode=emodewalk and the .text="".

Then just add a line at the end of your functions (the ones where you put the code for what happens when you click) named ResetMouse();

Am sure some expert can probably give you some code that will make my code useless, by making it doing it automaticly though... (laugh)
There are those who believe that life here began out there...

tor.brandt

@Cassiebsg:
Thanks for the reply!
Yeah, I'm really after a way to make it general, so I won't have to put those lines into every single function :smiley:

I actually managed to get it to work with room functions (i.e. non-GUI/inv item functions):
Code: ags
function on_mouse_click(MouseButton button)
{
  if (IsGamePaused() == 1)
  {
  }
  
  else if (button == eMouseLeft)
  {
   Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
   mouse.Mode = eModeWalk;
   lblActionText.Text = "";
  }
  
  else if (button == eMouseLeftInv)
  {
    InventoryItem* item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    item.RunInteraction(mouse.Mode);
    mouse.Mode = eModeWalk;
    lblActionText.Text = "";
  }
}


I'm not sure if this solution will cause problems in some cases I haven't yet thought of, though...?

As you see, I also attempted doing something similar for inventory items (I set "override built-in inventory..." to True in General settings to make it work), and it actually works - but now, since the built-in handling of inv items is disabled, when I left click on an inv item, it only carries out the "use inv item alone" function, so that I'm not able to use an inv item with something else.

SMF spam blocked by CleanTalk