Memory: variables
Math and comparing values
Calculations, and one value against another.
On this page
Anywhere the editor asks for a number, you can give it a small calculation instead. That lets a value depend on other values: a score that is kills times ten, a price that goes up with your reputation, a cost that halves once you have a discount.
Where you can calculate#
A number can be a calculation in all of these places:
- Set to, Add and Subtract on a choice or an arrival.
- Both ends of Roll a number from … to …, and the percent in Set to yes some % of the time.
- The position in Get the item at a position in a list.
- The number you add to a list of numbers.
The simple row#
By default a number is a small row of three parts: a first operand, an operation, and a second operand.

- Each operand is either a fixed number you type or one of your number values. Pick a number from the dropdown to type one.
- The operation menu offers +, −, × and ÷. Leave it on "(just that)" and the row is only the first operand.
Advanced formulas#
For anything longer, turn on advanced mode. Either click the small "advanced" link beside a calculation, or tick Advanced expressions in the three-dot menu next to Submit. The setting is remembered in your browser for every story, and a calculation that is too long for the simple row switches to advanced by itself.
Advanced mode is a single text box where you type the formula using your values' names and the symbols + − * / and brackets.
value… beside the box inserts a value's exact name, so you never have to guess a spelling. If the formula cannot be understood, a message appears under the box. For a formula with brackets or several steps, the editor also spells out how it reads it. A "simple" link switches back when the formula is short enough.
A few formulas:
kills * 10for a score.(strength + luck) / 2for an average.coins - priceto work out change.
Names use letters, numbers and underscores, with no spaces. That is why the editor asks for them when you create a value.
Rules of the road#
- Effects on a choice run from top to bottom, and each one sees the results of the ones above it. Set a value first, then use it in the next effect.
- Dividing by zero gives 0 and does not break anything.
- Fractions are kept exactly while the story runs. Where a number is printed in the text, it is rounded to two decimal places.
- A calculation only uses number values and numbers you type. It cannot look at text or lists.
Comparing one value to another#
A check on a number normally compares against a number you type. You can also compare against another number value. In the check, open the dropdown where the number goes and pick a value instead of a number. Text checks can compare against another text value the same way.
That is enough for "the reader's strength is at least the guard's strength".
There is no arithmetic inside a check. If you need "strength plus luck is at least 10", calculate it first. Use + Set a value on arrival to set a helper value called power to strength + luck, then check power.
What it cannot do#
There are no functions such as rounding, minimum or maximum. Do these with a fork instead. To keep a value from going above 10, add a fork after the change that says "if coins is more than 10, set coins to 10", and otherwise carry on.
Next#
Calculations are predictable. To bring chance in, read Randomness.