X39 – User talk

From Bohemia Interactive Community
Jump to navigation Jump to search
(Started rewriting https://community.bistudio.com/wiki/SQF_syntax)
 
m (Blanking)
Tag: Blanking
 
(68 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__TOC__
<code style="display: inline;">Status Quo Function</code> is the successor of <code style="display: inline;">[[SQS_syntax|Status Quo Script]]</code> which is deprecated since [[Armed Assault]].


== Language Structure ==
The SQF Language is fairly simple in how it is built.
In fact: there are barely any actual language structures at all.
The functionality is provided via so called ''operators'' (or more commonly known [[Category:Scripting_Commands_Arma_3|scripting commands]]).
Those operators are one of the following types: Nular, Unary or Binary.
=== Nular Operators ===
A Nular Operator is more or less a computed variable. Each time accessed, it will return the current state of something.
However, it will not automatically update when its state has changed.
Consider following example on a map with eg. 5 units:
<span style="color: #008000">//Put the result of [[allUnits]] into a [[Variables|variable]].</span>
_unitsArray = [[allUnits]];
<span style="color: #008000">//Display the current array size using [[systemChat]].</span>
[[systemChat]] [[str]] [[count]] _unitsArray;
<span style="color: #008000">//Create a new unit in the player group.</span>
[[group]] [[player]] [[createUnit]] ["B_RangeMaster_F", [[position]] [[player]], [], 0, "FORM"];
<span style="color: #008000">//Output the array size again</span>
[[systemChat]] [[str]] [[count]] _unitsArray;
<span style="color: #008000">//Output the size of [[allUnits]]</span>
[[systemChat]] [[str]] [[count]] [[allUnits]];
Now, what would the output of this look like?
System: 5
System: 5
System: 6
As you can see, <code style="display: inline;">_unitsArray</code> was not automatically updated.
The reason for this is because [[allUnits]] and other Nular commands just return the current state of something and do not return a reference to eg. an [[Array]] containing all units.
It is generated each time, which is why some of theese commands are extensive
=== Unary Operators ===
=== Binary Operators ===
== Rules Of Precedence ==
{|
|'''Lowest Precedence''' 1
|<code>[[a or b|<nowiki>||</nowiki>]] [[a or b|or]]</code>
|-
|2
|<code>[[and|&&]] [[and]]</code>
|-
|3
|<code>[[==]] [[!=]] [[a_greater_b|&gt;]] [[a_less_b|&lt;]] [[a_less=_b|&gt;=]] [[a_less=_b|&lt;=]] [[config_greater_greater_name|&gt;&gt;]]</code>
|-
|4
|''ALL BINARY OPERATORS''
|-
|5
|<code>[[else]]</code>
|-
|6
|<code>[[a_plus_b|+]] [[a_minus_b|-]] [[max]] [[min]]</code>
|-
|7
|<code>[[a_*_b|*]] [[a_/_b|/]] [[mod|%]] [[mod]] [[atan2]]</code>
|-
|8
|<code>[[a_^_b|^]]</code>
|-
|9
|''ALL UNARY OPERATORS''
|-
|'''Highest Precedence''' 10
|''ALL NULAR OPERATORS, VARIABLES OR VALUES''
|}
<!-- [[Category: Syntax]] [[Category:Scripting Topics]] -->

Latest revision as of 22:12, 18 November 2019