Magic Variables: Difference between revisions
Jump to navigation
Jump to search
Mossarelli (talk | contribs) No edit summary |
Lou Montana (talk | contribs) (Add _thisScript and categories) |
||
Line 2: | Line 2: | ||
=== Introduction === | === Introduction === | ||
'''Magic variables''' are engine maintained [[Variables|variables]] that serve a specific purpose within a given scope and are often used by the engine to push data to a given [[Script (File)|script]] or [[Code|code]] fragment. They are usually no longer present after leaving the scope (e.g. after code execution | '''Magic variables''' are engine maintained [[Variables|variables]] that serve a specific purpose within a given scope and are often used by the engine to push data to a given [[Script (File)|script]] or [[Code|code]] fragment. They are usually no longer present after leaving the scope (e.g. after code execution or after a [[forEach]] statement). | ||
=== Uses === | === 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 [[throw|thrown]] exception in the try block | |||
* '''_thisScript''': is the [[spawn|spawned]] script handle from within itself since {{arma3}} | |||
[[Category: Scripting Topics]] | |||
[[Category: Operation Flashpoint: Editing]] | |||
[[Category: ArmA: Editing]] | |||
[[Category: ArmA 2: Editing]] | |||
[[Category: Arma 3: Editing]] |
Revision as of 00:41, 3 May 2018
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