Project Mammut Wiki
Project Mammut is currently in open beta. The UI is being updated a lot during this time, and you may run into bugs. If you'd like to help develop the engine or suggest features, come find us on Bluesky or Discord.

Logic Reference

Written 8 Aug 2026 · Requires Mammut 0.6.2+

Curly-brace blocks ({...}) handle variables, conditionals, and loops directly inside chapter content. Default variables are declared in the Variables Manager, but more variables can be added by your code during runtime.

Printing a variable

{$playerName}

Shorthand for printing a single variable. For more control, use print:

{print($playerName)}
{print($playerName, "the traveler")}
{print($playerName, fallback="the traveler")}
{print($playerName, fallback="the traveler", cap=true)}
  • The first form prints the variable, or nothing if it's undefined/null.
  • A second positional argument (or fallback=) is shown instead when the variable is unset.
  • cap=true capitalizes the first letter of the result.

Setting a variable

{set($relationship, $relationship + 1)}
{set($playerName, "Sam")}

Writes straight through to the project's variable store (Store.Set, see Coding), so a Store.Register listener in a scene script sees the change immediately, and {$var} prints elsewhere reflect it on their next render.

Conditionals

{if ($metAlice == true)
Alice waves at you from across the room.
} else {
A stranger glances at you, then looks away.
}

The else block is optional. Conditions are evaluated as JS-like expressions (see "Expression syntax" below): comparisons, boolean logic, arithmetic, and ternaries all work.

Loops

{for ($i in range(0,3))
Item number {$i}
}
  • range(start, end) expands to start, start+1, ..., end-1.
  • You can also loop over an actual array variable: {for ($item in $inventory) ... }.
  • Looping over a plain number counts from 0 up to, but not including, that number.

Logging from content

{log($someVariable)}

Prints the evaluated value to the console via the runtime logger. Handy for debugging a chapter without needing to jump into a scene script.

Expression syntax

Expressions (conditions, set values, loop ranges) support a restricted, JS-like grammar: arithmetic (+ - * /), comparisons (< > <= >= == !=), boolean logic (&& ||), ternaries (? :), and string/array/object literals. $varName anywhere in an expression is substituted with that variable's current value before evaluating.