Math Expressions
The Evaluate Math Expression and If Math Expression events as well as any events supporting Script Values allow mathematical expressions to be used for performing calculations.
Expressions allow you to use many mathematical operations such as:
+
add-
subtract*
multiply/
divide==
equal to!=
not equal to>=
greater than or equal to
You are also able to use the following functions:
min(a, b)
return the minimum of two valuesa
andb
max(a, b)
return the maximum of two valuesa
andb
abs(a)
return the absolute value ofa
atan2(a, b)
return the 2-argument arctangent ofa
andb
isqrt(a)
return the square root ofa
rounded down to nearest integerrnd(a)
return a random number greater than0
and less thana
arr(a, b)
return the value on indexb
for the array with numbera
, first array has value ofa
= 1
When you want to combine multiple conditions in your code, you can use boolean logic operators:
-
||
or: This operator is used when you want to check if at least one of the conditions is true.
For example, if you write$Local0 == 0 || $Local1 == 0
, it means "if either variable Local0 equals 0 or variable Local1 equals 0". -
&&
and: This operator is used when you want to check if all conditions are true. For example, if you write$Local0 == 0 && $Local1 == 0
, it means "if both variable Local0 equals 0 and variable Local1 equals 0". -
!
not: This operator is used when you want to invert the truth value of a condition.
For example, if you write!($Local0 == 0)
, it means "if variable Local0 does not equal 0".
You can use variables in expressions by typing $
and searching for the variable's name.
You can also use global values in expressions by typing #
and searching for the global value's name.
Don't forget the variable access $
nor the global value access #
.