Magic Variables: Difference between revisions
Killzone Kid (talk | contribs) No edit summary |
Lou Montana (talk | contribs) m (Text replacement - "\{\{ArgTitle *\| *([^\|]+) *\| *([1-6]) *\|" to "{{ArgTitle|$2|$1|") |
||
Line 14: | Line 14: | ||
{{ArgTitle|_y | {{ArgTitle|4|_y|{{GVI|arma3|2.02}}}} | ||
Iterating over a [[HashMap]] with [[forEach]] will return the key as [[#x|_x]] and the value as [[#y|_y]]. | Iterating over a [[HashMap]] with [[forEach]] will return the key as [[#x|_x]] and the value as [[#y|_y]]. | ||
{{ArgTitle|_exception | {{ArgTitle|4|_exception|{{GVI|arma1|1.00}}}} | ||
[[Exception handling]] using a [[try]]-[[catch]] statement declares this variable which contains details about the [[throw|thrown]] exception in the try block. | [[Exception handling]] using a [[try]]-[[catch]] statement declares this variable which contains details about the [[throw|thrown]] exception in the try block. | ||
Line 25: | Line 25: | ||
Represents the (zero-based) index of a [[forEach]] [[#x|_x]] element. | Represents the (zero-based) index of a [[forEach]] [[#x|_x]] element. | ||
{{ArgTitle|_thisEventHandler | {{ArgTitle|4|_thisEventHandler|{{GVI|arma3|1.54}}}} | ||
The index for Event Handlers added with [[addEventHandler]], [[addMPEventHandler]] or [[addMissionEventHandler]]. | The index for Event Handlers added with [[addEventHandler]], [[addMPEventHandler]] or [[addMissionEventHandler]]. | ||
{{ArgTitle|_thisEvent | {{ArgTitle|4|_thisEvent|{{GVI|arma3|2.06}}}} | ||
The name of the Event added with [[addEventHandler]], [[addMPEventHandler]] or [[addMissionEventHandler]] as well as for config types EHs. | The name of the Event added with [[addEventHandler]], [[addMPEventHandler]] or [[addMissionEventHandler]] as well as for config types EHs. | ||
{{ArgTitle|_thisArgs | {{ArgTitle|4|_thisArgs|{{GVI|arma3|2.04}}}} | ||
Additional Event Handler arguments available with [[addMissionEventHandler]] | Additional Event Handler arguments available with [[addMissionEventHandler]] | ||
{{ArgTitle|_thisFSM | {{ArgTitle|4|_thisFSM|{{GVI|arma3|1.54}}}} | ||
The [[FSM]] id for FSMs executed with [[execFSM]]. | The [[FSM]] id for FSMs executed with [[execFSM]]. | ||
{{ArgTitle|_thisScript | {{ArgTitle|4|_thisScript|{{GVI|arma3|1.54}}}} | ||
The [[call|called]] or [[spawn|spawned]] [[Script (Handle)|script handle]] from within itself. | The [[call|called]] or [[spawn|spawned]] [[Script (Handle)|script handle]] from within itself. | ||
Line 46: | Line 46: | ||
{{ArgTitle|_fnc_scriptName | {{ArgTitle|4|_fnc_scriptName|{{GVI|arma3|1.00}}}} | ||
{{Feature|Informative|not engine-maintained, but added by functions_f/'''initFunctions.sqf''' script – see [[scriptName]]}} | {{Feature|Informative|not engine-maintained, but added by functions_f/'''initFunctions.sqf''' script – see [[scriptName]]}} | ||
From within a [[:Category:Functions|Function]], the '''TAG_fnc_functionName''' function name as string (e.g. "myTag_fnc_myFunction") | From within a [[:Category:Functions|Function]], the '''TAG_fnc_functionName''' function name as string (e.g. "myTag_fnc_myFunction") | ||
{{ArgTitle|_fnc_scriptNameParent | {{ArgTitle|4|_fnc_scriptNameParent|{{GVI|arma3|1.00}}}} | ||
{{Feature|Informative|not engine-maintained, but added by functions_f/'''initFunctions.sqf''' script – see [[scriptName]]}} | {{Feature|Informative|not engine-maintained, but added by functions_f/'''initFunctions.sqf''' script – see [[scriptName]]}} | ||
From within a [[:Category:Functions|Function]], name of the function that called the current one ([[#fnc_scriptName|_fnc_scriptName]] used when not defined) | From within a [[:Category:Functions|Function]], name of the function that called the current one ([[#fnc_scriptName|_fnc_scriptName]] used when not defined) |
Revision as of 00:43, 9 August 2021
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).
_this
Is used to make arguments of a script call (call, exec, execVM, spawn) visible and accessible to the script, also used in Event Handlers to pass appropriate params.
_x
Represents the current element during a loop with: apply, count, configClasses, configProperties, findIf, forEach, select.
_y
Iterating over a HashMap with forEach will return the key as _x and the value as _y.
_exception
Exception handling using a try-catch statement declares this variable which contains details about the thrown exception in the try block.
_forEachIndex
Represents the (zero-based) index of a forEach _x element.
_thisEventHandler
The index for Event Handlers added with addEventHandler, addMPEventHandler or addMissionEventHandler.
_thisEvent
The name of the Event added with addEventHandler, addMPEventHandler or addMissionEventHandler as well as for config types EHs.
_thisArgs
Additional Event Handler arguments available with addMissionEventHandler
_thisFSM
The FSM id for FSMs executed with execFSM.
_thisScript
The called or spawned script handle from within itself.
_time
SQS ONLY. The time elapsed since the script started running.
_fnc_scriptName
From within a Function, the TAG_fnc_functionName function name as string (e.g. "myTag_fnc_myFunction")
_fnc_scriptNameParent
From within a Function, name of the function that called the current one (_fnc_scriptName used when not defined)
this
- In Addons' config files (e.g. UserActions, onInit, etc.): The object the entry belongs to
- In Dialogs: The player unit that activated control (e.g. via mouseEnter). false if non-activated
- In Object's "Init" line: The object the init line belongs to
- In Triggers
- In Waypoints
- "Condition" or "On Activation/Deactivation" line: The group leader that completed the respective waypoint (or driver, if waypoint is assigned to a vehicle)
thisList
Variable defined by Triggers and Waypoints:
- Triggers:
- accessible within the Condition, On Activation or On Deactivation script
- defines an array of objects that have been detected by the trigger (same as what is returned by the list command)
- thisList in a trigger's On Deactivation field seems to be undefined, and should not be used. It will either return an empty array, or possibly the contents of a different trigger.
- Waypoints:
- accessible within the Condition or On Activation script
- defines an array containing all group members that completed the respective waypoint
thisTrigger
Refers to the trigger object itself - accessible within the Condition, On Activation or On Deactivation script.