Your first game
Three rooms, one item, one locked door. Save this as mygame.zaytun:
title: "The Short Way Out"
start: cell
flag haveKey = false
room cell "A Cell" {
description: "Four walls of damp brick. A door, north, and a loose stone in the floor."
exit north -> corridor if haveKey else "The door is locked. Obviously."
item loose_stone
}
room corridor "Corridor" {
description: "A corridor going east, towards daylight."
exit south -> cell
exit east -> outside
}
room outside "Outside" {
description: "Grass. Weather. The rest of your life."
on enter { finish "You are out. THE END." }
}
item loose_stone "loose stone" {
aliases: "stone", "floor"
fixed: true
examine: "One brick in the floor sits proud of the rest."
on use {
if haveKey {
print "The hollow under the stone is empty now."
} else {
print "You lever the stone up. Underneath, wrapped in cloth: a key."
set haveKey = true
}
}
}
Compile and play it:
./zaytunc/zaytunc mygame.zaytun # writes mygame.zaytunb
./zaytunplay/zaytunplay mygame.zaytunb
Then type use stone, north, east. That is a complete game — a start room, a gate that depends on state, something to do, and an ending.
One ordering rule worth knowing early: an on enter block runs before the room is described, so anything it prints appears above the room's name. That is usually what you want — an ambush, a trap, a scene that sets up the arrival — and it has one consequence worth seeing now: the finish above ends the turn where it stands, so Outside and its description are never printed at all. What the player reads last is the ending itself. See On enter.
Everything else in this handbook is a variation on those four ideas.