Conditions and Numeric Expressions
Expressions let story scripts make decisions from current game data, or calculate a formula into a number. You can read them as “compare query results” or “calculate several numbers before passing the result into a command”.
Quick Entry Points
Section titled “Quick Entry Points”There are three common entry points:
Condition expression: leftValue[operator]rightValueInteger expression: [&formula&]Float expression: [@formula@]Query directives can be placed inside expressions. The game replaces [$...$] or [%...%] with query results first, then performs comparison or calculation.
Condition Expressions
Section titled “Condition Expressions”Condition expressions answer whether something is true. The most common form has a value on the left, a comparison operator in the middle, and a value on the right:
[$player_money$][>=]100This is true when player money is at least 100.
Multiple conditions can be combined:
[$result_code$][=]1|[$player_money$][>=]100[$player:level$][>=]3&[$player_money$][>]100The first line means “the result is 1, or player money is at least 100”. The second line means “player level is at least 3, and money is greater than 100”.
& means “and”; | means “or”. & has higher priority than |. Use parentheses to change the evaluation order:
([$result_code$][=]1|[$result_code$][=]2)&[$player_money$][>=]100When comparing numbers, you can use greater than, less than, greater than or equal to, and less than or equal to. If you are not sure both sides are numbers, prefer [=] or [<>]. To check whether a value is inside a candidate set, use [in] or [notin]:
[$story_mode$][in]story_a,story_b,story_cNumeric Expressions
Section titled “Numeric Expressions”Numeric expressions calculate a formula into a number. Use [&...&] when you need an integer, and [@...@] when you need a decimal number.
[&1+2*3&][@1/3@]The first line returns integer 7; the second returns approximately 0.33. Formulas support addition, subtraction, multiplication, division, remainder, exponentiation, and parentheses.
You can also place query directives inside formulas:
[&[$player_money$]/10&]This queries player money first, divides it by 10, and returns an integer result.
Built-in functions are written around the formula:
[&@max(1+2*3,8)&][&@min(1+2*3,8)&][&@random(1,2,3)&]@max returns the larger value, @min returns the smaller value, and @random randomly selects one of the given results.
Reference
Section titled “Reference”Loading expression guide...