Game Development Community

Check if mouse is held down or any other key

by frostwind · in Torque 3D Beginner · 09/28/2013 (4:22 pm) · 3 replies

I used to use this function alot but i cannot find it anywhere so i was wondering if anyone knew
basically if i press a key or press my mouse button the console will echo something.
Thanks!


NOTE: Love the community here, it's really nice, 3rd day of being here :P thanks everyone.

EDIT: If you could, I would want to know both Client and Server-sided functions of this. Thanks again.

#1
09/28/2013 (8:52 pm)
default.bind.cs is the script file.

I believe its called function mouseFire

Its client sided only, the engine handles input transmission to the server.
#2
09/28/2013 (10:45 pm)
No. Thats not it. Mouse fire simulates you holding down the left mouse button
#3
09/29/2013 (12:52 am)
All input from the mouse/keyboard/etc happens on the client. The mouseFire function is bound to the button press something like this:
moveMap.bind(mouse, button0, mouseFire);
That means every time mouse button 0 is pressed or released, call mouseFire with an argument that's 1 when pressed, and 0 when released. You can insert your own function in there instead of (or as well as) mouseFire.

To make the server do something, you can either use commandToServer from inside the function you bind to the mouse button, or use the $mvSomething global variables for specific movement events (like, mouseFire uses $mvTrigger0, which makes the player fire their gun).

I wrote a tutorial on the input system here, though it doesn't use the default script template, so you might have to do a bit of interpretation to apply it to the regular scripts.