When
This formula allows you to specify branches in your overall formula, enabling you to return different things depending on the conditions you specify and the state of the character / resource.
In contrast with the WhenEffect, the When formula needs at least one
branch to evaluate to true, as it always should return a value. It is
recommended to always include a clause like this at the end of the clause
list to ensure that one always matches:
{
"condition": {
"type": "constant",
"value": true,
"value_type": "bool"
},
"components": {
/* Default value to be returned here */
}
}
Returns
special
JSON Format
{
"type": "when",
"clauses": ...
}
RPG Script
This component can be written in RPG Script as:
when {
cond1 -> value1,
cond2 -> value2,
else -> fallback
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
clauses | List<WhenClause> | ✓ | A list of conditions and associated components that should be evaluated and whose value should be returned as a value from this formula if the given condition is satisfied. Only the first clause whose condition is true will have its components evaluated and its value returned. The rest will be ignored, so the order matters. You can specify as many clauses as you want. |