Enforce Script Syntax – Arma Reforger
Enforce Script is the language that is used by the Enfusion engine first introduced in DayZ Standalone. It is an Object-Oriented scripting language that works with objects and classes and is similar to the C# programming language.
Data Types
There are many types of data, the most common being:
| Type | Description | Example | Wikipedia |
|---|---|---|---|
| Native types | |||
| a bool, a.k.a true or false (and nothing else!) | see Bool | ||
| an integer, a.k.a a whole number e.g 1, 42, -10, etc. | see Integer | ||
| a floating point value, a.k.a a partial number e.g 1.0, 4.2, -0.1, etc | see Float | ||
| a text value, a.k.a a sequence of characters, e.g "Hello there" | see String | ||
| an array of three float values e.g { 1.0, 42.2, 66.6 } | see Vector | ||
| Objects | |||
class |
an object able to hold properties and methods. | see Object Oriented Programming Basics | see Class |
enum |
a structure having static values "listed" as its properties. | see Enum | |
| static array | a static array of elements (of a type) - it cannot contain a mix of types. | see Array | |
| a dynamic array of elements (of a type) - it cannot contain a mix of types. | see Array | ||
| a set of unique elements, it can only contain one type of elements. | see Set | ||
| a map constituted of key-value pairs, where the key aspect is used to obtain the value. | see Map | ||
Object-Oriented Programming
See Object Oriented Programming Basics and Object Oriented Programming Advanced Usage.
Operations
Assignation
Assignation operations convert the value to the expected type; see below:
// adding int and int
int result = 1 + 2; // result == 3
// adding float and float
float result = 1.25 + 2.75; // result == 4
// adding int and float
int result = 1 + 0.9; // result == 1 - int truncates a float result
int result = 0.9 + 0.9 + 0.9; // result == 2 - 2.7 truncated to 2
float result = 0.9 + 0.9 + 0.9; // result == 2.7
float result = 1 + 1.9; // result == 2.9
float result = 1.9 + 1; // result == 2.9
bool invalid = new SCR_Ray(); // error: Types 'SCR_Ray' and 'bool' are unrelated
SCR_Ray instance = new SCR_Ray();
bool valid = instance; // valid == true
bool result = 42; // result == true
Logic
SCR_Ray instance = new SCR_Ray();
if (instance) // identical to "instance != null"
Print("Instance exists");
else
Print("Instance does not exists");
string text;
if (text) // identical to "!text.IsEmpty()"
Print("Text is not empty");
else
Print("Text is empty");
int val = 42; // same with float
if (val) // identical to "val != 0"
Print("Val is not zero");
else
Print("Val is zero");