Game syntax help

A practical reference for writing games in the browser editor.

Complete example

This is the smallest useful branching game. Paste it into the editor and press Validate.

---
title: The Lantern Path
start: crossroads
---

# Page: crossroads
You find a lantern beside two paths.

### Choices
@choice "Take the woodland path" -> woods
@choice "Follow the river" -> river

# Page: woods
The lantern reveals a safe trail home.
@ending won "Home by Lantern Light"

# Page: river
The current carries away the path markers.
@ending lost "Lost Beside the River"

Metadata

Put the title and starting page near the top. Separator lines are optional but make the manifest easier to read.

---
title: The Lantern Path
description: Follow a mysterious lantern through the woods.
author: Alex
tags: fantasy, mystery
start: crossroads
---

description: is the short summary shown on the game’s library card. The editor sets author: to the signed-in user's friendly username. Add comma-separated tags: that describe the game's genre, setting, themes, or style; players can use them to filter the library. The value of start: must match an existing page ID.

Pages and choices

Every scene begins with a page declaration. Choices contain the button text and destination page.

# Page: platform

## The Empty Platform

The station clock has stopped at midnight.

### Choices
@choice "Board the train" -> carriage
@choice "Leave the station" -> street

Blank lines start new paragraphs. Markdown headings beginning with ## are displayed as headings; # Page: is reserved for page declarations.

Variables and personalization

Declare integer, string, float, and boolean variables outside pages, then insert them into story text with braces.

@int time = 6
@str heroName = "Alex"

# Page: arrival
The clock strikes {time}. "You're late, {heroName}," says the guard.

Variable names begin with a letter or underscore and are case-sensitive when used in expressions.

Use @set inside a page to update a declared variable. The right-hand side is an expression and may use the variable's current value.

@int visits = 0
@str trail = ""
@float temperature = 19.5
@bool lampOn = false

# Page: counter
@set visits = visits + 1
@set trail = trail + "+"
@set temperature = temperature + 0.5
@set lampOn = not lampOn

Visits: {visits}
Trail: {trail}

@choice "Refresh" -> counter

Conditional, once, and random text

Conditions

@if time >= 6 and heroName == 'Alex'
The conductor prepares to close the doors.
@end

Expressions can use variables, inventoryCount, ownership such as player has "Key", random(1, 6), and chance(25).

Show text once

@once
A rat darts into a crack in the wall.
@end

Choose random text

@random
Rain rattles against the window.
@or
The train whistle echoes outside.
@or
Steam hides the end of the platform.
@end

Random blocks need at least two alternatives. Text blocks cannot be nested.

Transitions and endings

An automatic transition shows a Continue button. A transition page cannot also contain choices or an ending.

# Page: departure
The whistle sounds and the train begins to move.
@goto carriage

End a route with a won or lost result and a short title:

@ending won "The Journey Begins"
@ending lost "The Train Left Without You"

Read the FAQ or open the game editor.

An unhandled error has occurred. Reload 🗙