-
Notifications
You must be signed in to change notification settings - Fork 26
Scripting Language Reference
Scripting language was designed to be Java-like but more noob-friendly. API methods are also designed to be noob-proof. It should be hard to crash the game if you write stupid script.
You can see language grammar file here: https://github.com/Zergatul/cheatutils/blob/master/src/main/java/com/zergatul/cheatutils/ScriptingLanguage.jj
The following tokens are operators:
+ - * / % !/ !%
~ ! && ||
< > <= >= == !=
Boolean value, same as in Java. Default value false.
32-bit signed integer value, same as in Java. Default value 0.
64-bit floating point value, same as double in Java. Default value 0.0.
Immutable string, like in Java. As opposed to Java cannot be null, can be compared with == or != operators.
If left or right operand is int and other is float, int is cast to float. Examples:
float x = 2.1;
if (2.1 > 2) { // int literal is converted to 2.0 float
module.doSomething();
}Same happens when you declare variable.
When you specify arguments for method call, arguments can be implicitly converted: int -> float, int -> string. Compiler finds acceptable method overload which requires minimum type conversions.
Example:
int x = module.isEnabled() ? 123 : 456;Examples:
b = x > y; // greater than
b = x < y; // less than
b = x >= y; // greater than or equals
b = x <= y; // less than or equalsExamples:
boolean b1 = x && y; // and
boolean b2 = x || y; // or
boolean b3 = !b2; // notExamples:
x = -y;
x = +y;
x = ~y; // binary inversionExamples:
x = a + b;
x = a - b;
x = a * b;
x = a / b;
x = a % b; // remainder
x = a !/ b; // floor div, example -5 !/ 16 = -1
x = a !% b; // floor mod, example -5 !% 16 = 11Examples:
boolean b; // declaration with no initial value
int x = y + 10; // declaration with initial valueWhen you declare variable with no initial value it implicitly receives default initial value for its type. Variable can be accessed only within block it was declared.
Example:
x = x + y + module.getSomething();Example:
module.setSomething(123);The if statement is used for conditional execution. May contain optional else block. Examples:
if (x == y) {
module.doSomething();
}
if (a > b) {
module.doX();
} else {
module.doY();
}