Author Topic: Lock Mouse  (Read 2824 times)

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Lock Mouse
« on: 19 Apr 2016, 08:06 »
It has come to my attention over the past few games of mine that it would be great to have a lock mouse command.

EG
Throwing an object at a Hotspot using mouse x y and if you then move the mouse before the object reaches its destination it causes the object to veer off course. If you could command to 'lock the mouse' on mouse click and returning once move has finished this would stop the object veering off course.

I for one would find this very useful instead of going around the houses (nod)

slasher


Gurok

  • Rottwheelers
  • When life hands you lemons, combine them with the mop
    • I can help with AGS tutoring
    • Best Innovation Award Winner 2016, for improving and extending the AGS scripting language
    • I can help with proof reading
    • I can help with scripting
    • Gurok worked on one or more games that won an AGS Award!
    •  
    • Gurok worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #1 on: 19 Apr 2016, 08:14 »
Just store the coordinates at the time of clicking in some variables:

Code: [Select]
int mouseClickX;
int mouseClickY;

function on_mouse_click(MouseButton button)
{
    if(button == eMouseLeft)
    {
        mouseClickX = mouse.x;
        mouseClickY = mouse.y;
    }
}

If you really want to lock the mouse down, you could probably do it with Mouse.SetBounds:

Code: [Select]
Mouse.SetBounds(mouse.x, mouse.y, mouse.x, mouse.y);
and then all zeroes to unlock it:

Code: [Select]
Mouse.SetBounds(0, 0, 0, 0);
« Last Edit: 19 Apr 2016, 08:24 by Gurok »

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #2 on: 19 Apr 2016, 09:19 »
Hi Gurok,

thank you for your reply... this i did know but just seeing if lock mouse would be feasible in implementing.

cheers ;)

Re: Lock Mouse
« Reply #3 on: 28 Apr 2016, 11:59 »
This is posted in the Editor development.
Do you mean locking mouse in the Editor window (room editing pane)?

Also, I am afraid I hardly understand your example
Quote
Throwing an object at a Hotspot using mouse x y and if you then move the mouse before the object reaches its destination it causes the object to veer off course. If you could command to 'lock the mouse' on mouse click and returning once move has finished this would stop the object veering off course.

Do you, perhaps, mean "snap" the mouse cursor to existing objects?
« Last Edit: 28 Apr 2016, 12:02 by Crimson Wizard »

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #4 on: 28 Apr 2016, 12:19 »
Quote
Do you mean locking mouse in the Editor window (room editing pane)?
No. In-game.

Quote
Also, I am afraid I hardly understand your example
Throw a rock (object) when active inv is a rock at  hotspots x y.





Re: Lock Mouse
« Reply #5 on: 28 Apr 2016, 12:31 »
EDIT: sorry, I guess I had a moment of absent-mindness. I understand what you are talking about now.

But, could you elaborate why cannot not (or do not want) you use Mouse.SetBounds() or store coordinates as Gurok suggested?
Or, in other words, what exactly are you suggesting that would be different from Mouse.SetBounds()?
« Last Edit: 28 Apr 2016, 12:51 by Crimson Wizard »

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #6 on: 29 Apr 2016, 10:53 »
well, Lockmouse is quicker to type (nod)

Either way Mouse.SetBounds() works i know.

Oh. whilst i'm here LockUserControls option with Cutscenes to stop dioalog skipping would be more than useful in rare cases when you have to sync speech text with separate audio speech..
« Last Edit: 29 Apr 2016, 10:56 by slasher »

Re: Lock Mouse
« Reply #7 on: 29 Apr 2016, 14:56 »
well, Lockmouse is quicker to type (nod)

Either way Mouse.SetBounds() works i know.

I see.
If that is a problem, you could create your own function in a custom module to use in your games -
Code: Adventure Game Studio
  1. void Lockmouse()
  2. {
  3.     Mouse.SetBounds(mouse.x, mouse.y, mouse.x, mouse.y);
  4. }
  5.  
  6. void Unlockmouse()
  7. {
  8.     Mouse.SetBounds(0, 0, 0, 0);
  9. }
  10.  
that is actually a way to go in programming and scripting when you do not want to retype something long over and over.

I feel reluctant about adding another builtin function that does what existing function already does, just for particular case.

Of course opinions on this may vary... My personal view was always that built in set of functions should provide only what cannot be done or too hard to do in scripts, and for the other cases script modules should be written.


Oh. whilst i'm here LockUserControls option with Cutscenes to stop dioalog skipping would be more than useful in rare cases when you have to sync speech text with separate audio speech..
You can define how user may or may not skip the speech with Speech.SkipStyle (or SetSkipSpeech() function in old versions). For example, setting Speech.SkipStyle = eSkipTime will make player unable to use mouse or keys to skip dialog.
« Last Edit: 29 Apr 2016, 15:08 by Crimson Wizard »

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #8 on: 29 Apr 2016, 15:30 »
Thank you Crimson...

solves a few issues..

cheers

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #9 on: 29 Apr 2016, 17:57 »
Just like to point out that skipping dialogue speech is important, specially if you're replaying a game, accidentally hit the same dialog option or something like that.
I would not replay a game where I can't skip ahead on the dialog, if I already know that particular line, cause it would just frustrate me and I would end up giving up on it.

But that is just me, maybe I'm alone in this department...
There are those who believe that life here began out there...

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on one or more games that won an AGS Award!
    •  
    • Slasher worked on one or more games that was nominated for an AGS Award!
Re: Lock Mouse
« Reply #10 on: 30 Apr 2016, 07:31 »
The ability to lock dialog for just a few vital seconds is not game breaking and if used with Cutscene correctly will not make all that much difference.

However, having to sit through minutes of unskippable drivel is another story.

But this may be off subject....