What does @forca mean?
A variable is a name representing a value on the sheet. @forca reads Strength; @forca + 2 takes that value and adds 2. If Strength is 3, the result is 5. The @ symbol tells the editor that you are using a variable.
Choose the names suggested by the editor. The names in this guide are examples and may differ on your template. A name containing spaces can be written as @{Força Bruta}. Modifiers and maximums may have their own names, such as @forca_mod and @vida_max.
A variable name that does not exist is read as 0. If a result looks wrong, check its name and the value shown in the test. Use a period for decimals, such as 1.5. Use * to multiply, such as @forca * 2. Put text inside quotes.
@nivel + 2
floor((@forca - 10) / 2)
clamp(@vida + 5, 0, @vida_max)
@{Força Bruta} * 2
How to write a question with a Yes or No answer
A condition is a question. @vida > 0 asks whether Health is above zero. @forca >= 3 asks whether Strength is 3 or more. > means greater; >= means greater or equal; < and <= make the opposite comparisons.
== asks whether two values are equal, and != whether they differ. and requires both conditions to be met. or requires at least one. not reverses the answer. Use parentheses to clarify which parts should be compared together.
If chooses a whole path. Within a formula, if(condition, value if yes, value if no) or condition ? yes : no chooses only a value. Text comparisons are exact: Fight and fight differ. Look up these forms when your rule needs them.
@forca >= 3 and @vida > 0
$event.attribute == "agilidade"
if(@nivel >= 5, 2, 1)
@vida <= 0 ? "Down" : "Standing"
$event, $sheet and earlier step outputs
These forms are for more advanced rules. $event reads information about the action that started the rule. $sheet reads sheet information. $("Step name") reads a result provided by an earlier step.
In a roll rule, $event may offer formula, total, dice, skillName and attribute. Fields vary by event. Before rolling, total and dice do not exist yet.
$sheet contains lists of attributes, skills, values such as Health and Mana, fields, cards and variables, plus memory. A list is a collection of items; [0] accesses the first. null means “no value”, such as a missing field or a path that did not run.
To use $("Step name"), copy Step name exactly and keep that name unique in the diagram. The step must have run earlier on the same path. Ask returns the answer directly; do not add .answer. Choose returns data about the selected item, which may include name, total and targets.
When a value may be missing, coalesce(value, default) uses the default only when the value is null. It does not replace 0, false or empty text. Look up these examples when you need to pass one step's result to the next.
$("Roll dice").total
$("Ask")
$("Choose").targets.misc
$sheet.skills[0].name
coalesce($sheet.memory.usos, 0)
How to put a value inside text or a dice formula
In a number or condition field, write the formula directly. In a text or dice field in Expression mode, put only the calculated part between {{ and }}. For example, Total: {{ @forca + 2 }} shows Total: 5 when Strength is 3.
To roll 1d20, use Roll dice. An expression alone does not make a roll. Dice formulas can use sheet variables; the dice guide explains options such as keeping the highest die and exploding dice.
Text in expression mode:
Total: {{ $("Roll dice").total }}
Dice in expression mode:
1d20 + {{ @forca_mod }}
Condition in expression mode:
@vida > 0
Ready-made formulas for common situations
A function is a ready-made operation in a formula. max(@dano - 2, 0) subtracts 2 from damage but never goes below 0. clamp(@vida + 5, 0, @vida_max) adds 5 to Health and keeps the result between 0 and its maximum.
min picks the lowest value; max, the highest. floor rounds down; ceil rounds up; round rounds to the nearest, with ties away from zero; trunc/fix removes the decimal part toward zero.
For lists, sum adds, avg averages and len counts items. first and last pick the first and last. contains checks whether something is present. join combines items into text. For text, upper, lower and trim change capitalization and spaces at the ends. number tries to read a value as a number.
Additional reference for when needed: abs, sign, sqrt, cbrt, pow, exp, log, log10, log2, mod, sin, cos, tan, asin, acos, atan and atan2, plus pi, e and tau. The in-editor expression guide helps you look up functions.
max(@dano - 2, 0)
ceil(@nivel / 4)
round(2.5)
contains(["forca", "agilidade"], $event.attribute)
join($event.dice, " + ")