Enforce Script Syntax – DayZ
Jump to navigation
Jump to search
(More clear) |
|||
Line 4: | Line 4: | ||
== Operators == | == Operators == | ||
'''Operator Priority''': Priority of operators is similar than in C language, [https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence more info]. | |||
=== Arithmetic Operators === | === Arithmetic Operators === | ||
Line 18: | Line 19: | ||
|- | |- | ||
| Divide || {{Inline code|/}} | | Divide || {{Inline code|/}} | ||
|- | |||
| Modulo || {{Inline code|%}} | |||
|} | |} | ||
Line 41: | Line 44: | ||
|} | |} | ||
=== | === Relational (conditional) === | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 54: | Line 57: | ||
|- | |- | ||
| Less or equal to the value || {{Inline code|<{{=}}}} | | Less or equal to the value || {{Inline code|<{{=}}}} | ||
|} | |||
=== Others === | |||
{| class="wikitable" | |||
|- | |||
! Category !! Operator|- | |||
|- | |||
| Logical || <nowiki>&&</nowiki>, <nowiki>||</nowiki> | |||
|- | |||
| Bitwise || <nowiki>&, |, ~</nowiki> | |||
|- | |||
| String || + | |||
|- | |||
| Shift || <<, >> | |||
|- | |||
| Assignment || <nowiki>=</nowiki> | |||
|- | |||
| Indexing || [] | |||
|- | |||
| Negation || ! | |||
|} | |} | ||
Revision as of 16:09, 10 January 2019
Enforce Script is the language that is used by the Enfusion engine first introduced in DayZ Standalone. It is a Object-Oriented Scripting Language (OOP) that works with objects and classes.
Operators
Operator Priority: Priority of operators is similar than in C language, more info.
Arithmetic Operators
Operation | Symbol |
---|---|
Add | +
|
Subtract | -
|
Multiply | *
|
Divide | /
|
Modulo | %
|
Assignments
Operation | Symbol |
---|---|
Assign value to variable | =
|
Increment variable by value | +=
|
Decrement variable by value | -=
|
Multiply variable by value | *=
|
Divide variable by value | /=
|
Increment variable by 1 | ++
|
Decrement variable by 1 | --
|
Relational (conditional)
Operation | Symbol |
---|---|
More than value | >
|
Less than value | <
|
More or equal to the value | >=
|
Less or equal to the value | <=
|
Others
Category | - |
---|---|
Logical | &&, || |
Bitwise | &, |, ~ |
String | + |
Shift | <<, >> |
Assignment | = |
Indexing | [] |
Negation | ! |
Classes and Objects
Classes can be seen as a blueprint of an object. An object is an instance of a class. A class can have more than one object.
Basic Class Example
class MyClass
{
private string _test;
void MyClass()
{
// Constructor that will be called when class gets instantiated
}
void myMethod()
{
// Some code here
}
string getTest()
{
return _test;
}
string setTest(value)
{
_test = value;
}
}
Instantiate and Use
Use the new
operator to instantiate a class. You can access methods or attributes by using dot notation.
Example
class MyClass { int attributeExample = 1; public MyClass() { // Constructor } public void myMethod() { return "This is a string return"; } } MyClass myClassI = new MyClass(); myClassI.attributeExample // 1 myClassI.myMethod // "This is a string return"
Basic Script Example
MyClass myClass = new MyClass();
myClass.myMethod();
myClass.setTest("Hello, Enforce Script!");
string str = myClass.getTest(); // str is now "Hello, Enforce Script!"
Modded class
In order to get your custom code to work and function on top of another class already in the game, a modded class is where you want to turn to.
modded class PlayerBase
{
override void EEKilled(Object killer)
{
// This will call the method in which you are overriding.
// Do this if you want to keep the original functionality
super.EEKilled(killer);
// Custom code here (i.e. Print(killer.GetIdentity().GetName()))
}
}