Magic Variables: Difference between revisions
Lou Montana (talk | contribs) (Add _thisScript and categories) |
Lou Montana (talk | contribs) (Add more details thanks to commy2 and sldt1ck - TODO: merge this here) |
||
Line 1: | Line 1: | ||
== 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 or after a [[forEach]] statement). | '''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). | ||
=== | |||
''See also: [[this]]'' | |||
== Usage == | |||
==== _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 loop with: [[apply]], [[count]], [[configClasses]], [[configProperties]], [[findIf]], [[forEach]], [[select]]. | |||
==== _forEachIndex ==== | |||
represents the (zero-based) index of a [[forEach]] [[#x|_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}}. | |||
==== _thisEventHandler ==== | |||
Since Arma 3 v.1.63.137807, the script handle (not the EH index!) for Event Handlers added with [[addEventHandler]] or [[addMPEventHandler]]. | |||
==== _pos,_alt,_shift,_units ==== | |||
See [[onMapSingleClick]] | |||
==== _id,_uid,_name,_jip,_owner ==== | |||
See [[onPlayerConnected]] | |||
[[Category: Scripting Topics]] | [[Category: Scripting Topics]] |
Revision as of 08:21, 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).
See also: this
Usage
_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 loop with: apply, count, configClasses, configProperties, findIf, forEach, select.
_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.
_thisEventHandler
Since Arma 3 v.1.63.137807, the script handle (not the EH index!) for Event Handlers added with addEventHandler or addMPEventHandler.
_pos,_alt,_shift,_units
See onMapSingleClick