Automatically set mouse mode after interaction

Started by wynni2, Mon 16/06/2008 04:29:59

Previous topic - Next topic

wynni2

hello -

i'm very new with ags, and i've run into a problem with what seems like a simple task.

after running any interaction i'd like the mouse cursor to automatically set itself to "walk."  is there a way to do this without manually adding "mouse.Mode=eModeWalkTo;" at the end of every interaction in the game?

i tried editing the on_mouse_click function to change the cursor after processing the mouse click, but doing so cancels the intended interaction. 

any suggestions?

Khris

At the top of the global script, add
Code: ags
bool after_int;

Inside on_mouse_click(), directly after "if (button==eMouseLeft) { ...", add
Code: ags
    after_int = true;

Inside repeatedly_execute, add
Code: ags
  if (after_int) {
    after_int = false;
    mouse.Mode = eModeWalkto;
  }

Not tested.

Ishmael

If KhrisMUC's suggestion doesn't work, start a few loop timer in the on_mouse_click instead and check for it's expiration in rep_ex and set to walk mode after that. Might need some fine tuning still, tho.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

monkey0506

You could just:

Code: ags
function on_mouse_click(MouseButton button) {
  if (button == eMouseLeft) {
    // blah
  }
  else {
    // blah
  }
  mouse.Mode = eModeWalkto;
}


If you really need it reset after the interaction finishes, that becomes a bit more complicated...

Khris

I still didn't do any tests, so bear with me ;)

monkey, your suggestion looks like what I guess wynni2 has already tried. But ProcessClick(..., mouse.Mode); gets queued and it looks like it does use whatever the value of mouse.Mode is at the time it's executed, not called.

My method was e.g. used by Proskrito's MI template to reset the action bar to "Walk to"/normal text color after an interaction, so it should work.

wynni2

i bore with you, and it works like a charm.  thanks.

monkey0506

#6
Even if the function is queued, the parameters should be passed by value not by reference, so it shouldn't make a difference...?

If it does I'd say it's a bug in AGS?

Based off my reading of the first post, I was imagining that wynni was changing the mouse mode at the top of the script, thinking the interaction had already been processed.

Khris

Quote from: wynni2 on Mon 16/06/2008 04:29:59i tried editing the on_mouse_click function to change the cursor **after** processing the mouse click, but doing so cancels the intended interaction.

I _still_ didn't test it though. ;)

SMF spam blocked by CleanTalk