Code vs. Strings: Difference between revisions
mNo edit summary |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(13 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
'' | Since {{arma1}} the convention to use quotation marks for [[String]]s and curly braces for [[Code]] has been formalised. | ||
Exceptions, however, do exist. For example [[onMapSingleClick]] and [[onDoubleClick]].<br> | |||
When scripting, {{hl|'abc'}} or {{hl|"abc"}} generally indicates a [[String]] data type, and brackets {{hl|{ }<nowiki/>}} indicate [[Code]] data type. | |||
In {{ofp}}, many language constructs (including [[forEach]]) use the concept of "code strings". | |||
Code is passed as a string to them and they interpret it as code if they wish. Since version 1.85, code is also accepted. | |||
<sqf> | |||
// {{ofp}} / {{arma1}} only! | |||
"_x setDammage 1" forEach _units; | |||
// from {{ofp}} v1.85+ up to {{arma3}} | |||
{ _x setDamage 1 } forEach _units; | |||
</sqf> | |||
[[Category: | == Code Commands == | ||
'''Code commands''' are any commands from the scripting language expecting a coded statement string as one of their parameters. | |||
Earlier engines accepted code as such when it was provided as a [[String]] using quotation marks, ''or'' using braces. | |||
Since {{arma1}} the engine '''specifically''' requires braces. | |||
Thus, because the way the engine determines whether it is dealing with code has changed, this list is presented here. | |||
Commands passed as data type [[Code]]: Last updated: {{GVI|arma3|2.02}} | |||
{{Columns|3| | |||
* [[&&]] | |||
* [[a or b|<nowiki/>||]] | |||
* [[addPublicVariableEventHandler]] | |||
* [[and]] | |||
* [[apply]] | |||
* [[call]] | |||
* [[catch]] | |||
* [[collect3DENHistory]] | |||
* [[count]] | |||
* [[default]] | |||
* [[deleteAt]] | |||
* [[do]] | |||
* [[else]] | |||
* [[exitWith]] | |||
* [[findIf]] | |||
* [[forEachMemberAgent]] | |||
* [[forEachMemberTeam]] | |||
* [[forEachMember]] | |||
* [[forEach]] | |||
* [[for]] | |||
* [[get]] | |||
* [[if]] | |||
* [[in]] | |||
* [[isFinal]] | |||
* [[isNil]] | |||
* [[onCommandModeChanged]] | |||
* [[onEachFrame]] | |||
* [[onGroupIconClick]] | |||
* [[onGroupIconOverEnter]] | |||
* [[onGroupIconOverLeave]] | |||
* [[onHCGroupSelectionChanged]] | |||
* [[onMapSingleClick]] | |||
* [[onPlayerConnected]] | |||
* [[onPlayerDisconnected]] | |||
* [[onPreloadFinished]] | |||
* [[onPreloadStarted]] | |||
* [[onTeamSwitch]] | |||
* [[or]] | |||
* [[select]] | |||
* [[spawn]] | |||
* [[switch]] | |||
* [[then]] | |||
* [[toString]] | |||
* [[try]] | |||
* [[waitUntil]] | |||
* [[while]] | |||
* [[with]] | |||
}} | |||
== String Commands == | |||
Commands passed as data type [[String]]: | |||
* map [[onDoubleClick]] "[[Code]]" | |||
* map [[onMapSingleClick]] "[[Code]]" | |||
[[Category: Scripting Topics]] |
Latest revision as of 14:52, 14 November 2023
Since Armed Assault the convention to use quotation marks for Strings and curly braces for Code has been formalised.
Exceptions, however, do exist. For example onMapSingleClick and onDoubleClick.
When scripting, 'abc' or "abc" generally indicates a String data type, and brackets { } indicate Code data type.
In Operation Flashpoint, many language constructs (including forEach) use the concept of "code strings". Code is passed as a string to them and they interpret it as code if they wish. Since version 1.85, code is also accepted.
Code Commands
Code commands are any commands from the scripting language expecting a coded statement string as one of their parameters. Earlier engines accepted code as such when it was provided as a String using quotation marks, or using braces. Since Armed Assault the engine specifically requires braces. Thus, because the way the engine determines whether it is dealing with code has changed, this list is presented here.
Commands passed as data type Code: Last updated: 2.02
- &&
- ||
- addPublicVariableEventHandler
- and
- apply
- call
- catch
- collect3DENHistory
- count
- default
- deleteAt
- do
- else
- exitWith
- findIf
- forEachMemberAgent
- forEachMemberTeam
- forEachMember
- forEach
- for
- get
- if
- in
- isFinal
- isNil
- onCommandModeChanged
- onEachFrame
- onGroupIconClick
- onGroupIconOverEnter
- onGroupIconOverLeave
- onHCGroupSelectionChanged
- onMapSingleClick
- onPlayerConnected
- onPlayerDisconnected
- onPreloadFinished
- onPreloadStarted
- onTeamSwitch
- or
- select
- spawn
- switch
- then
- toString
- try
- waitUntil
- while
- with
String Commands
Commands passed as data type String:
- map onDoubleClick "Code"
- map onMapSingleClick "Code"