Identifier: Difference between revisions
Category: Syntax
Lou Montana (talk | contribs) m (Text replacement - "[[OFPEC tags" to "[[Scripting Tags") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
An [[Identifier]] is the name given to a [[Variables|variable]] that the scripter can choose: It is the name that ''identifies'' the variable. | An [[Identifier]] is the name given to a [[Variables|variable]] that the scripter can choose: It is the name that ''identifies'' the variable. | ||
== Rules == | == Rules == | ||
{| class="wikitable float-right" | {| class="wikitable float-right" | ||
|+ Regex: {{hl|[a-zA-Z_][a-zA-Z0-9_]*}} | |+ Regex: {{hl|[a-zA-Z_][a-zA-Z0-9_]*}} | ||
| Line 17: | Line 19: | ||
* _my{{Color|red|#}}localVar | * _my{{Color|red|#}}localVar | ||
* _guy1{{Color|red|&}}2var | * _guy1{{Color|red|&}}2var | ||
* {{Color|red|player}} | * {{Color|red|player}} ([[player]]) | ||
|} | |} | ||
Binding rules for identifiers: | Binding rules for identifiers: | ||
| Line 41: | Line 43: | ||
{{cc|'''{{Color|purple|Tag}}'''_identifier}} | {{cc|'''{{Color|purple|Tag}}'''_identifier}} | ||
<span style="color: purple; font-weight: bold">UNIQUETAG</span>_player = [[player]]; | <span style="color: purple; font-weight: bold">UNIQUETAG</span>_player = [[player]]; | ||
Latest revision as of 18:19, 11 January 2026
An Identifier is the name given to a variable that the scripter can choose: It is the name that identifies the variable.
Rules
| Valid | Invalid |
|---|---|
|
|
Binding rules for identifiers:
- Identifiers may consist of any ASCII text characters (a-z, A-Z), numbers (0-9) and underscores (_).
- Identifiers must not start with a number (e.g "9myVariable" is invalid).
- Identifiers of local variables must start with an underscore.
- Identifiers are case-insensitive.
- Identifiers cannot be the same as reserved words (e.g commands and functions).
Recommendations
It is recommended to write local variable identifiers in camel case syntax. This makes identifiers more readable:
It is also recommended to prefix global variable identifiers with your tag in order to avoid any potential conflict between addons, scripts and missions:
// Tag_identifier UNIQUETAG_player = player;