---
name: "Magic Variables"
type: topic
aliases: ["fnc scriptName", "forEachIndex", "this", "thisActivator", "thisArgs", "thisList", "thisScript", "thisTrigger", "thisargs", "x", "y"]
source: https://community.bistudio.com/wiki/Magic_Variables
revid: 378809
updated: 2026-06-30T19:25:43Z
---

# Magic Variables

__NOEDITSECTION__
Magic variables are engine-maintained [variables](../topics/Variables.md) that serve a specific purpose within a given scope and are often used by the engine to provide data to a script or [code](../topics/Code.md) fragment.

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

#### _this

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

#### _x

Represents the current element during iteration with [apply](../commands/apply.md), [count](../commands/count.md), [configClasses](../commands/configClasses.md), [configProperties](../commands/configProperties.md), [findIf](../commands/findIf.md), [forEach](../commands/forEach.md) and [select](../commands/select.md).

#### _y (Arma 3 v2.02)

Iterating over a [HashMap](../topics/HashMap.md) with [forEach](../commands/forEach.md) will return the key as [_x](../topics/Magic_Variables.md#x) and the value as [_y](../topics/Magic_Variables.md#y).

#### _exception (Armed Assault v1.00)

Exception handling using a [try](../commands/try.md)-[catch](../commands/catch.md)-statement declares this variable which contains details about the [thrown](../commands/throw.md) exception in the [try](../commands/try.md)-block.

#### _fnc_scriptName (Arma 3 v1.00)

> [!NOTE]
> Not engine-maintained, but added by `functions_f/initFunctions.sqf` – see [scriptName](../commands/scriptName.md).

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](../commands/scriptName.md).

Within a Function, the name of the function that called the current function (same as [_fnc_scriptName](../topics/Magic_Variables.md#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](../commands/forEach.md)- / [forEachReversed](../commands/forEachReversed.md)-loop.

#### _self (Arma 3 v2.14)

Available in HashMapObject methods. Contains the HashMapObject instance that the method was invoked on (see [createHashMapObject](../commands/createHashMapObject.md)).

#### _thisArgs (Arma 3 v2.04)

Additional Event Handler arguments available with [addMissionEventHandler](../commands/addMissionEventHandler.md).

#### _thisEvent (Arma 3 v2.06)

The name of the Event added with [addEventHandler](../commands/addEventHandler.md), [addMPEventHandler](../commands/addMPEventHandler.md), [addMissionEventHandler](../commands/addMissionEventHandler.md),[addUserActionEventHandler](../commands/addUserActionEventHandler.md), [ctrlAddEventHandler](../commands/ctrlAddEventHandler.md) and [displayAddEventHandler](../commands/displayAddEventHandler.md), as well as for config types EHs.

#### _thisEventHandler (Arma 3 v1.64)

The index for Event Handlers added with [addEventHandler](../commands/addEventHandler.md), [addMPEventHandler](../commands/addMPEventHandler.md), [addMissionEventHandler](../commands/addMissionEventHandler.md), [addUserActionEventHandler](../commands/addUserActionEventHandler.md), [ctrlAddEventHandler](../commands/ctrlAddEventHandler.md) and [displayAddEventHandler](../commands/displayAddEventHandler.md).

#### _thisFSM (Arma 3 v1.54)

The FSM ID for FSMs executed with [execFSM](../commands/execFSM.md).

#### _thisScript (Arma 3 v1.54)

The [Script Handle](../topics/Script_Handle.md) of a script started with [execVM](../commands/execVM.md), [call](../commands/call.md) or [spawn](../commands/spawn.md).

#### _thisScriptedEventHandler (Arma 3 v1.68)

The index for Scripted Event Handlers added with [BIS_fnc_addScriptedEventHandler](../functions/BIS_fnc_addScriptedEventHandler.md).

#### _time

> [!WARNING]
> SQS only.

The time elapsed since the script started running.

#### this

- **Addon Config Files** (e.g. UserActions, onInit, etc.)**:** The object to which the entry belongs.
- **Dialogs:** The player unit that activated control (e.g. via mouseEnter). [false](../commands/false.md) if non-activated.
- **Object Init Fields:** The object to which the init field belongs.
- **Triggers:**
  - *Condition*: The [Boolean](../topics/Boolean.md) return value of the Trigger's condition (e.g. "East Not Present").
  - *On Activation* and *On Deactivation*: Seems to always return [false](../commands/false.md).
- **Waypoints:**
  - *Condition*, *On Activation* and *On Deactivation*: The group leader that completed the waypoint (or the driver, if the waypoint is assigned to a vehicle).

#### thisList

- **Triggers:**
  - Accessible in the *Condition*, *On Activation* and *On Deactivation* code.
  - Defines an array of objects that have been detected by the trigger (same as what is returned by the [list](../commands/list.md) command).
  - Seems to be undefined in the *On Deactivation* expression and should not be used. It will either be an empty array, or possibly the contents of a different trigger.
- **Waypoints:**
  - Accessible within the *Condition* or *On Activation* code.
  - Defines an array containing all group members that completed the waypoint.

#### 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](../topics/Object.md), which activated this trigger. Default: the trigger [Object](../topics/Object.md) itself.

<sub>Source: [BI Community Wiki — Magic Variables](https://community.bistudio.com/wiki/Magic_Variables) (revision 378809).</sub>
