Math
A Math expression can be used to perform a calculation on some values as part of a Statement.
Operand
The Operand type in Dragonscript 2E is a catch-all for Literals, Properties and the result of Math expressions.
Operators
The following operators are supported in Math expressions.
| Symbol | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division (rounding down) |
# | Division (rounding up) |
Additionally, the following functions are also supported:
max(left: Operand, right: Operand): Math
Returns the larger value between left or right.
min(left: Operand, right: Operand): Math
Returns the smaller value between left or right.
Examples
level / 2
Half the character's level, rounded down.
max(0, 1 + attribute_modifier(intelligence))
1 + Intelligence modifier, ensuring the result is non-negative.