Skip to Content
Stoatly Docs
Formulas

Create a formula

Write an expression and see its result on a record straight away. Type it as text or build it from blocks, and switch between the two whenever you like without losing your work. You'll need to be an admin or a schema designer.

Create one

Open the Formulas tab

Open an object type and choose the Formulas tab, then New Formula.

Choose how to write it

Stoatly asks "How do you want to write it?". Choose Type it to write the expression directly, or Build it from blocks to pick fields and operators from a palette. Both build the same formula.

Name it

Give the formula a name. Stoatly creates a slug from it and shows the full name, such as weapon.formulas.dps. Add a description if it helps your team.

Write the expression

Fields, parameters and other formulas appear as suggestions as you type. See below.

Test it

Use Run on Record to pick a record and see the result. Fix anything the editor flags.

Save the draft

Choose Save draft. The formula appears with a Draft badge until you send it in a pull request.

The new formula page, asking how to write it, with Type it and Build it from blocks.

Type it

Write the formula as an expression, for example damage * (1 + crit_chance). Suggestions appear as you type:

  • A field name inserts the field.
  • A name starting with $ is a parameter.
  • A name followed by a bracket calls another formula on the same object type.

Use the arrow keys to move through the suggestions, Enter or Tab to take one and Escape to close the list. If the text can't be read, the editor shows "Cannot read this Formula" with the problem.

A formula in Text mode, with the Reads as sentence below it and a result panel for a chosen record.

Build it from blocks

The editor has a Text and a Blocks switch at the top. In blocks mode, the palette has four tabs: Fields, Functions, Operators and Parameters. Choose a block to place it in the expression. Hovering a block explains what it does, for example "Keep a value between a minimum and maximum". An empty slot stays empty until you fill it, and the formula can't be saved with one.

The same formula in Blocks mode, built from nested blocks, with the palette tabs underneath.

Reads as

Under the editor, Reads as restates the formula in plain English. It says the same thing whichever way you wrote it, so use it to check that the formula means what you intended.

Try it on a record

The side panel has two parts:

  • Run on Record lets you pick a record, including one that's still a draft. It shows the result, the type of the result, and the value of every field the formula reads.
  • Also check shows the result on the next few records, so you can spot odd outliers. Choose one to switch to it.

If the object type has no records yet, create one to see the formula run.

Setup

The Setup panel holds the slug, the description, the Returns type, the parameters and Show syntax tree, which shows the expression as data.

When it can't be saved

A banner reads "Cannot save. Fix the following" and lists the problems. Common ones are a missing name or slug, a parse error and empty slots.

Discard a draft

Choose Discard to throw away your unsent changes to a formula. A formula that has never shipped is removed.

On this page