Game Development Community

binding problems

by Anthony Rosenbaum · in General Discussion · 01/23/2002 (3:47 pm) · 2 replies

ok I am slowly learing the scripting this this particular problem deals with default.bind.cs
first off I aded a echo to the gun to make sure echo worked like so
function mouseFire(%val)
{
       echo("you hit fire");
     $mvTriggerCount0 += $mvTriggerCount0 & 1 == %val ? 2 : 1;
}

moveMap.bind( mouse, button0, mouseFire );
then I wanted to get the other mouse button to work so I did this
function mouseJet(%val)
{
         echo("YOU JUST HIT MOUSE2");
   $mvTriggerCount3 += $mvTriggerCount3 & 1 == %val ? 2 : 1;
}

moveMap.bind( mouse, button1, mouseJet );

the firing works, in fact it displays the message twice to the console, the other does not. . . .WHAT IS WRONG?!?!? what am I missing PLEASE can anyone help?
Anthony

#1
01/24/2002 (12:02 pm)
Can't offer a reason why the second button fails, but the first echo may be done twice cause the function is being called on both press and release (just a guess).
#2
06/23/2003 (7:46 pm)
This is true, pressing a mouse button will call the function with a %val of 1 (I think it's 1. Echo %val to be sure). Releasing the button will call the same function with a %val of 0. Put this in your function to quit this behavior.
if (%val) {
    echo("you hit fire");
} else {
    echo("you stopped hitting fire");
}

I know it's been a year and a half since you posted this, but I thought others might want to know. Also, the mouse wheel is zaxis. It's %val is 140 for wheel forward and -140 for wheel backwards so it's a slightly different game. Helpful examples:
moveMap.bind(mouse, zaxis, wheelFunction);
moveMap.bind(keyboard, "numpadadd", zoomCameraOut);
moveMap.bind(keyboard, "numpadminus", zoomCameraIn);
moveMap.bind(keyboard, "right", rotateCameraLeft);
moveMap.bind(keyboard, "left", rotateCameraRight);
moveMap.bind(keyboard, "up", rotateCameraUp);
moveMap.bind(keyboard, "down", rotateCameraDown);
moveMap.bind(keyboard, "insert", resetCamera);