Enforce Script Syntax – Arma Reforger
Lou Montana (talk | contribs) (Page creation) |
Lou Montana (talk | contribs) m (Add content) |
||
| Line 5: | Line 5: | ||
{{Feature|dayz|For {{dayz}}, see {{Link|DayZ:Enforce Script Syntax}}.}} | {{Feature|dayz|For {{dayz}}, see {{Link|DayZ:Enforce Script Syntax}}.}} | ||
== Data Types == | |||
See {{Link|Arma Reforger:Scripting: Values#Types}}. | |||
== Object-Oriented Programming == | |||
See {{Link|Arma Reforger:Object Oriented Programming Basics}} and {{Link|Arma Reforger:Object Oriented Programming Advanced Usage}}. | |||
== Operations == | |||
=== Assignation === | |||
Assignation operations cast the first value to the expected type; see below: | |||
<enforce> | |||
// 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 | |||
SCR_Ray instance = new SCR_Ray(); | |||
bool valid = instance; // valid == true | |||
</enforce> | |||
=== Logic === | |||
<enforce> | |||
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"); | |||
</enforce> | |||
{{Feature|important|<enforce inline>if (intValue)</enforce> is '''not''' recommended by {{Link|Arma Reforger:Scripting: Best Practices}}.}} | |||
Revision as of 00:03, 9 December 2025
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
See Scripting: Values - Types.
Object-Oriented Programming
See Object Oriented Programming Basics and Object Oriented Programming Advanced Usage.
Operations
Assignation
Assignation operations cast the first 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
SCR_Ray instance = new SCR_Ray();
bool valid = instance; // valid == 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");