Arma 3 Scripting

Topic in Scripting

Magic Variables

Also available as Markdown and JSON, or read the original wiki page.

NOEDITSECTION Magic variables are engine-maintained variables that serve a specific purpose within a given scope and are often used by the engine to provide data to a script or code fragment.

They are usually no longer present after leaving the scope (e.g. after code execution or after a forEach-statement).

_this

Used to make the arguments of a script call (call, exec, execVM, spawn) visible and accessible to the script. Also used by Event Handlers to provide parameters.

_x

Represents the current element during iteration with apply, count, configClasses, configProperties, findIf, forEach and select.

_y (Arma 3 v2.02)

Iterating over a HashMap with forEach will return the key as _x and the value as _y.

_exception (Armed Assault v1.00)

Exception handling using a try-catch-statement declares this variable which contains details about the thrown exception in the try-block.

_fnc_scriptName (Arma 3 v1.00)

Note

Not engine-maintained, but added by functions_f/initFunctions.sqf – see scriptName.

Within a Function, the TAG_fnc_functionName function name (e.g. "myTag_fnc_myFunction").

_fnc_scriptNameParent (Arma 3 v1.00)

Note

Not engine-maintained, but added by functions_f/initFunctions.sqf – see scriptName.

Within a Function, the name of the function that called the current function (same as _fnc_scriptName if the function was not called by another function).

_forEachIndex (Arma 2: Operation Arrowhead v1.55)

Represents the (zero-based) index of a forEach- / forEachReversed-loop.

_self (Arma 3 v2.14)

Available in HashMapObject methods. Contains the HashMapObject instance that the method was invoked on (see createHashMapObject).

_thisArgs (Arma 3 v2.04)

Additional Event Handler arguments available with addMissionEventHandler.

_thisEvent (Arma 3 v2.06)

The name of the Event added with addEventHandler, addMPEventHandler, addMissionEventHandler,addUserActionEventHandler, ctrlAddEventHandler and displayAddEventHandler, as well as for config types EHs.

_thisEventHandler (Arma 3 v1.64)

The index for Event Handlers added with addEventHandler, addMPEventHandler, addMissionEventHandler, addUserActionEventHandler, ctrlAddEventHandler and displayAddEventHandler.

_thisFSM (Arma 3 v1.54)

The FSM ID for FSMs executed with execFSM.

_thisScript (Arma 3 v1.54)

The Script Handle of a script started with execVM, call or spawn.

_thisScriptedEventHandler (Arma 3 v1.68)

The index for Scripted Event Handlers added with BIS_fnc_addScriptedEventHandler.

_time

Warning

SQS only.

The time elapsed since the script started running.

this

thisList

thisTrigger

Refers to the trigger object itself - accessible within the Condition, On Activation and On Deactivation code.

thisActivator (Arma 3 v2.22)

Refers to an Object, which activated this trigger. Default: the trigger Object itself.