Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.22

Description

Description:

Simulates a user input, using a script or ASI.

Toggled options reset themselves, while other actions keep their state, until set to zero again.

Example:

If "MoveForward" setAction 1 is applied to a unit, the unit keeps walking forever (until it is stopped, using "MoveForward" setAction 0).

Be aware that some actions have to be reset to 0, before switching to an opposing action (for example, before switching from "CarForward" to "CarBack", one should wait until the vehicle is stationary). As the same applies to steering, but since it is not easy to determine the steering angle, a better option is to use negative values (for example, instead of "CarLeft" setAction .5, use "CarRight" setAction -.5).

In V2.08+, actions can be defined using their DIK KeyCodes (hexadecimal or decimal). This simulates pressing the respective key (for example, #17 to simulate the W key). Unlike assignments, using their name (for example, "MoveForward"), simulating keys executes any action assigned to this key (for example, if walking, then W executes "MoveForward", but when in a car it executes "CarForward").

Note: Be aware that number keys (at top of the keyboard) and Backspace cannot be simulated this way. Key combinations can be defined by passing an array with two elements - one for each key to be pressed.

Syntax

Syntax:action setAction amount
Parameters:

     V2.08+:
     action: Number - DIK KeyCodes, to simulate a key press.
     action: Array - Two DIK KeyCodes, to simulate a key combination.

  • amount: Number - Amount of input (e.g. to simulate a joystick). 0 to 1 for digital actions, -1 to 1 for analog.
Return Value:Nothing

Alternative Syntax

Syntax:[action,object] setAction amount (V1.31+)
Parameters:

     V2.08+:
     action: Number - DIK KeyCodes, to simulate a key press.
     action: Array - Two DIK KeyCodes, to simulate a key combination.

     V2.10+:
     object: Array - Turret definition, consisting of [vehicle name,turret path].

  • amount: Number - Amount of input.
Return Value:Nothing

Examples

Examples:
Player moves forward:
"moveforward" setaction 1;
Vehicle named "car0" moves forward:
["carforward", car0] setaction 1;
V2.08+: simulates pressing W for player (move forward):
17 setaction 1

V2.08+: simulates pressing LCtrl + LShift (toggle safety):
[29,42] setaction 1
V2.08+: simulates pressing W for "unit1" (move forward):
[17, unit1] setaction 1; 

V2.10+: Rotates turret [0] on "tank1" to the left:
["carAimLeft", [tank1,[0]]] setaction 1;

Demo mission, balancing a car on two wheels, using the setAction commands: balance.zip

Additional Information

See also: setExternalControl, remoteControl, inputAction, VBS Key Actions
Multiplayer:
Problems:

Notes