-
Notifications
You must be signed in to change notification settings - Fork 0
Language Guide
ffredyk edited this page Jul 23, 2026
·
1 revision
Complete guide to SQ# syntax, variables, operators, and core language features.
Statements end with ; (preferred) or ,:
_x = 5;
_y = 10;
_x = 5, _y = 10; // also valid// Line comment
/* Block comment
spanning multiple lines */- Local variables: start with
_—_myVar,_count,_x - Global variables: no
_prefix —myGlobal,SCORE - Case-insensitive:
_myVarand_MYVARare the same variable - Unicode letters allowed:
_žlutý,_переменная
Only = operator. No +=, -=, ++, --:
_x = 5;
_y = _x + 10;
_arr = [1, 2, 3];private _local = 42; // explicit declaration
_local = 42; // implicit (first assignment declares)
private _a, _b, _c; // multiple declaration (all nil)myGlobal = 100; // bare name = global (SQF style)
global HIGH_SCORE = 999; // explicit global keywordAssigning nil to a variable deletes it (matches SQF behavior):
_myVar = 42;
_myVar = nil; // _myVar no longer exists!
isNil "_myVar"; // truenil is still valid in arrays and comparisons:
_arr = [1, nil, 3]; // nil as array element — fine
if (_arr select 1 == nil) then { ... }; // comparison worksprivate _hp: number = 100; // typed local
private _name: string = ""; // optional, for clarity/tooling| Type | Examples |
|---|---|
| Number |
42, 3.14, -5, 1.5e10
|
| String |
"hello", 'hello', @"C:\path"
|
| Boolean |
true, false
|
| Nil | nil |
| Array |
[1, 2, 3], ["a", "b"]
|
| Code |
{ _x * 2 }, { sleep 1; }
|
| Op | Arity | Description |
|---|---|---|
+ |
binary | Addition / string concatenation |
- |
binary/unary | Subtraction / negation |
* |
binary | Multiplication |
/ |
binary | Division (zero divisor → error) |
% |
binary | Modulo |
^ |
binary | Power (exponentiation) |
min |
binary | Smaller of two |
max |
binary | Larger of two |
_result = 3 + 4; // 7
_result = 10 / 3; // 3.333...
_result = 2 ^ 8; // 256
_result = 5 min 3; // 3| Op | Description |
|---|---|
== |
Equal (strict, no type coercion) |
!= |
Not equal |
< |
Less than |
> |
Greater than |
<= |
Less than or equal |
>= |
Greater than or equal |
if (_hp <= 0) { handleDeath(); };
if (_name == "player") { ... };
"hello" == "HELLO"; // false (case-sensitive, unlike SQF!)| Op | Description |
|---|---|
! |
NOT |
&& |
AND (short-circuit) |
|| |
OR (short-circuit) |
if (_alive && _hp > 50) { attack(); }; // _hp only checked if _alive
_flag = !_done;Higher number = higher priority. Equal precedence → left-to-right.
| Prec | Category | Operators |
|---|---|---|
| 11 | Values, brackets | literals, (), [], {}, variables |
| 10 | Unary |
-x, !flag, count _arr, str _val
|
| 9 | Hash-select | _arr # index |
| 8 | Power | a ^ b |
| 7 | Mul/Div/Mod |
*, /, %
|
| 6 | Add/Sub/Min/Max |
+, -, min, max
|
| 5 | else | else |
| 4 | Binary commands |
select, pushBack, set, resize
|
| 3 | Comparisons |
==, !=, <, >, <=, >=
|
| 2 | AND | && |
| 1 | OR | || |
// Precedence in action:
_result = 3 + 4 * 2; // 11 (not 14) — * before +
_flag = _a > 0 && _b < 10; // comparisons before && — works as expectedEvery command takes exactly one expression on its right side:
| Arity | Pattern | Example |
|---|---|---|
| Nular |
cmd — no operands |
nil, player, true
|
| Unary | cmd <right> |
count _arr, str _val
|
| Binary | <left> cmd <right> |
_a + _b, _arr select 0
|
Commands needing 3+ parameters use an array on the right:
_arr set [idx, val] // 2 params packed into array
spawnOn ["AI", { code }] // scheduler name + code packed into array// Double-quoted (escape sequences supported)
_name = "Hello\nWorld"; // \n = newline
// Single-quoted (no escapes except '')
_path = 'C:\Users\Name'; // backslashes are literal
// Verbatim (no escapes at all)
_path = @"C:\Users\Name\Documents";
// Multi-line
_text = """
Line 1
Line 2
""";
// Interpolation (f-strings)
_msg = f"Player {_name} has {_hp} HP";| Bracket | Purpose |
|---|---|
() |
Grouping, precedence, command arguments |
[] |
Array literals, array-form command args |
{} |
Code blocks |
"" / ''
|
String literals |
- Type System — all types in detail
- Control Flow — if/while/for/switch/try-catch
- Functions & Code — call/spawn/execVM/compile
- Strings & Text — formatting, interpolation, manipulation
- Commands — full command reference
- Getting Started
- Language Guide
- Type System
- Control Flow
- Functions & Code
- Strings & Text
- Arrays & Collections
- Concurrency
- Promise System
- Thread Safety
- Host API & Embedding
- CLI Tool
- Bytecode Reference
- Multiplayer
- Syntax Sugar
- Optimization Guide
- Benchmarks
- count
- select
- pushBack
- append
- deleteAt
- deleteRange
- resize
- reverse
- sort
- find
- in
- forEach
- freeze
- thaw
- isFrozen
- currentScheduler
- clientOwner
- allSchedulers
- schedulerName
- schedulerExists
- schedulerBudget
- setSchedulerBudget
- fiberCount
- readyFiberCount
- waitingFiberCount
- schedulerLoad
- sendTo