Difference between revisions of "GetAnalogControlState"
m (→Required Arguments)
|Line 9:||Line 9:|
*'''control:''' The control that you want to
*'''control:''' The control that you want to the state of. See [[control names]] for a list of possible controls.
Latest revision as of 21:14, 8 July 2018
This retrieves the analog control state of a control. This is useful for detecting sensitive controls, such as those used on a joypad.
float getAnalogControlState ( string control )
- control: The control that you want to get the state of. See control names for a list of possible controls.
Returns a float between 0 and 1 indicating the amount the control is pressed.
This creates an /forwards command, which toggles your forwards control state between 0 and 1.
addCommandHandler( "forwards", function( ) if ( getAnalogControlState( "forwards" ) == 0 ) then setAnalogControlState( "forwards", 1 ) else setAnalogControlState( "forwards", 0 ) end end )