Expression operators
StoryBonsai expressions are built on the NCalc evaluator. This page lists every operator the manual promises to support. NCalc may accept additional grammar; treat anything not listed here as undocumented and subject to change.
Operators are grouped by kind below. Within each section, the operator is shown
with its symbol and a short example. For function-style operators (Length(x),
Min(a, b), etc.) see Expression functions.
Arithmetic
Addition
Adds two numbers, or joins text. When both operands are numbers, the result is the sum. If either operand is a string, the other side is converted to text and the two are joined with no space between them.
Symbol: +
1 + 2 // 3
"hello, " + var_player_name // "hello, Alice"
"score: " + var_hp // "score: 42"
Subtraction
Subtracts the right operand from the left.
Symbol: -
5 - 2 // 3
var_hp - var_damage
Multiplication
Multiplies two numbers.
Symbol: *
3 * 4 // 12
var_base_price * var_count
Division
Divides the left operand by the right. Result is a decimal for numeric inputs
(no integer truncation).
Symbol: /
10 / 4 // 2.5
var_total_cost / var_count
Modulo
Remainder after integer division.
Symbol: %
10 % 3 // 1
var_turn_count % 2 // alternate-turn flag
Comparison
Equality
True when the operands are equal. String comparison is
case-insensitive: "Apple" == "apple" is true.
Symbol: ==
var_score == 10
var_location == "tavern"
Inequality
True when the operands are not equal.
Symbol: !=
var_player_name != "Alice"
var_hp != 0
Greater than
True when the left operand is greater than the right.
Symbol: >
var_hp > 0
var_attempts > 3
Less than
True when the left operand is less than the right.
Symbol: <
var_level < 5
var_hunger < var_threshold
Greater than or equal
True when the left operand is greater than or equal to the right.
Symbol: >=
var_score >= 100
var_trust >= var_unlock_threshold
Less than or equal
True when the left operand is less than or equal to the right.
Symbol: <=
var_attempts <= 3
var_player_level <= var_scene_cap
Logical
Logical and
True when both operands are true. Also spelled and (case-insensitive).
Symbol: &&
var_has_key && var_door_closed
var_is_night and var_in_forest
Logical or
True when either operand is true. Also spelled or (case-insensitive).
Symbol: ||
var_helmet || var_shield
var_is_exhausted or var_is_injured
Logical not
True when the operand is false. Also spelled not (case-insensitive).
Symbol: !
!var_visited
not Played(node_intro)
Grouping
Parentheses
Parentheses control evaluation order. Standard precedence applies: multiplication and division bind tighter than addition and subtraction; comparison binds tighter than logical operators.
Symbol: ( )
(1 + 2) * 3 // 9
(var_hp > 0) && (var_mp > var_cost)