Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: wynni2 on Mon 16/06/2008 04:29:59

Title: Automatically set mouse mode after interaction
Post by: wynni2 on Mon 16/06/2008 04:29:59
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?
Title: Re: Automatically set mouse mode after interaction
Post by: Khris on Mon 16/06/2008 09:53:57
At the top of the global script, add
bool after_int;
Inside on_mouse_click(), directly after "if (button==eMouseLeft) { ...", add
    after_int = true;
Inside repeatedly_execute, add
  if (after_int) {
    after_int = false;
    mouse.Mode = eModeWalkto;
  }

Not tested.
Title: Re: Automatically set mouse mode after interaction
Post by: Ishmael on Mon 16/06/2008 15:12:13
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.
Title: Re: Automatically set mouse mode after interaction
Post by: monkey0506 on Tue 17/06/2008 03:01:15
You could just:

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...
Title: Re: Automatically set mouse mode after interaction
Post by: Khris on Tue 17/06/2008 09:30:49
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.
Title: Re: Automatically set mouse mode after interaction
Post by: wynni2 on Wed 18/06/2008 05:23:24
i bore with you, and it works like a charm.  thanks.
Title: Re: Automatically set mouse mode after interaction
Post by: monkey0506 on Thu 19/06/2008 01:38:49
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.
Title: Re: Automatically set mouse mode after interaction
Post by: Khris on Thu 19/06/2008 07:29:03
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. ;)