Sometimes typing in numbers won't cut it. Sometimes you need some calculation.
Remember that you can use more than two numbers at one, 1+1+1+1 would work fine as well.

A word of advice

Link to a-word-of-advice

When unexpected results happen in a calculation, it is very well possible that you used two different types.
For example 13 % 6.5 returns 1, even though the correct result is 0. Why? ZenScript always performs its calculations with two variables of the same type. For this, it converts the 2nd Type to match the first one. In this example, the calculation performed was 13 % 6, as the 2nd number (a double) was converted to match the first one (an Integer).

Always be careful about what two variable types you use and when in doubt, just use a print function to print the output to the log and confirm the results.

Arithmetic Operators

Link to arithmetic-operators

I'm pretty sure all of you know these already, don't you?

TokenTokenassignFunctionExample
Token
+
Tokenassign
+=
Function
Addition
Example
1+2
Token
-
Tokenassign
-=
Function
Substraction
Example
2-1
Token
*
Tokenassign
*=
Function
Multiplication
Example
1*1
Token
/
Tokenassign
/=
Function
Division
Example
2/2
Token
%
Tokenassign
%=
Function
Modulo
Example
13 % 6

Puts one thing at the and of the other

ZenScript
Copy
//prints "Hello World"
print("Hello" ~ " " ~ "World");

Calculation results

Link to calculation-results

A calculation usually ends up with a result. So what to do with that?

Assigning a variable

Link to assigning-a-variable

There are two ways of assigning a value to a variable:

ZenScript
Copy
var test = 0;

//Option 1:
//assigns test with the value 3 (1+2)
test = 1+2;

//Option 2:
//assigns test with 5 (3+2)
test = test + 2;

//Option 3:
//assigns test with 2 (5-3)
test -= 3;

Option 1 and 2 assign the return variable using the = token.
This is probably the easiest way for beginners and the only way if you want to assign a variable not used in the calculation.

Option 3 assigns the variable before the -= with the result of a normal subtraction.
All Operators on on this page have their respective assign tokens, check the table above.

Using the result otherwise

Link to using-the-result-otherwise

You can always use the result of a calculation in a function or a conditional statement:

ZenScript
Copy
//prints 4
print(3+1);

//removes the item on array[4]
recipes.remove(array[3+1]);

//
if(3+1 == 2*2) {print("Used a calculation!")}