Work out an equation
Do some maths and keep the answer for this run.
data.compute evaluates an equation and saves the answer for this run.
Settings
| Setting | What it does |
|---|---|
| Save as | The name to keep the answer under. The default is result. |
| Equation | The maths, such as round({option.amount} * 1.5, 2). |
Equations take numbers, + - * / %, brackets and comparisons (== != < <= > >=, which give 1 or 0), and these functions:
| Function | Gives |
|---|---|
round(x), round(x, 2) | x to a whole number, or to so many decimal places |
floor, ceil, trunc | Rounded down, up, or towards zero |
abs, sign | Without its sign, or -1, 0 or 1 |
min(…), max(…) | The least or most of up to 16 values |
clamp(x, low, high) | x kept between low and high |
pow(x, y), sqrt, exp, ln, log | Powers, roots and logarithms (log is base 10) |
random(), random(a, b) | A random number from 0 to 1, or from a to b |
randint(a, b) | A random whole number from a to b, both included |
Ways out
| Way out | Taken when |
|---|---|
Worked out | The equation gave a number. |
Not a number | It didn't, for example because a token was empty or text. |
Produces
{temp.name}, using the name from Save as.
Example
Roll a die with randint(1, 6), or compute a price with {option.quantity} * {row.price}, then use {temp.result} in a message.