Magic Variables: Difference between revisions
Lou Montana (talk | contribs) (Add _fnc_scriptName et _fnc_scriptNameParent) |
Lou Montana (talk | contribs) m (Add note to _fnc_scriptName and _fnc_scriptNameParent) |
||
Line 3: | Line 3: | ||
{{Cfg ref|abc}} | {{Cfg ref|abc}} | ||
== 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.<br>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.<br>They are usually no longer present after leaving the scope (e.g. after code execution or after a [[forEach]] statement). | ||
Line 46: | Line 46: | ||
==== _fnc_scriptName ==== | ==== _fnc_scriptName ==== | ||
</div> | </div> | ||
{{note|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") | ||
Line 52: | Line 53: | ||
==== _fnc_scriptNameParent ==== | ==== _fnc_scriptNameParent ==== | ||
</div> | </div> | ||
{{note|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 11:37, 14 May 2018
Template:Cfg ref Template:Cfg ref
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).
Generic
_this
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.
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.
_thisFSM
The FSM id for FSMs executed with execFSM.
_thisScript
The called or spawned script handle from within itself.
_fnc_scriptName
Template:note From within a Function, the TAG_fnc_functionName function name as string (e.g. "myTag_fnc_myFunction")
_fnc_scriptNameParent
Template:note 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 are currently fulfilling the trigger's condition (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.
Specifics
onMapSingleClick: _pos,_alt,_shift,_units
- See onMapSingleClick