BuildcordDocs

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

SettingWhat it does
Save asThe name to keep the answer under. The default is result.
EquationThe maths, such as round({option.amount} * 1.5, 2).

Equations take numbers, + - * / %, brackets and comparisons (== != < <= > >=, which give 1 or 0), and these functions:

FunctionGives
round(x), round(x, 2)x to a whole number, or to so many decimal places
floor, ceil, truncRounded down, up, or towards zero
abs, signWithout 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, logPowers, 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 outTaken when
Worked outThe equation gave a number.
Not a numberIt 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.

On this page