Magic Variables
Jump to navigation
Jump to search
Introduction
Magic variables are engine maintained variables that serve a specific purpose within a given scope and are often used by the engine to push data to a given script or code fragment. They are usually no longer present after leaving the scope (e.g. after code execution or after a forEach statement).
Uses
- _this: probably the most frequently used magic variable, which is used to make arguments of a script call (call, exec, execVM, spawn) visible and accessible to the script
- _x: represents the current element during a forEach or a count
- _forEachIndex: represents the (zero-based) index of a forEach _x
- thisList, thisTrigger: variable defined by Triggers, which are however only accessible within the activation or deactivation script.
- _exception: [Exception handling]] using a try..catch statement declares this variable which contains details about the thrown exception in the try block
- _thisScript: is the spawned script handle from within itself since Arma 3