Skip to content

About

A small engine for classic parser text adventures: a CRT terminal in the browser, worlds as data, and an optional LLM intent parser.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Brass Lantern

Classic parser text adventures in a CRT terminal, in the browser. Write your own game as data, or load a real Infocom-era story file. The demo plays the Zork trilogy.

Play the demo · Read the docs

═══════════════════════════════
INSTALLED CARTRIDGES
═══════════════════════════════
  1  SNACK ATTACK      native
  2  ZORK I            Z-machine v3
  3  ZORK II           Z-machine v3
  4  ZORK III          Z-machine v3
  5  ZORK I · NATIVE   native
[Type a number to insert a cartridge. EJECT brings you back here.]
[LOAD plays a Z-machine story file from your computer. It stays in this browser; nothing is uploaded.]
> 2
West of House
You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.
> open mailbox

Two ways to play

Write a world. A game is one TypeScript object: rooms, items, people, events and the rules that join them. The engine runs it, with no game code to write. You get:

  • gated rooms, use rules, gifts, dialogue that changes with progress, timed interruptions, hints, a score with ranks, and endings that remember what you did;
  • a forgiving parser, with synonyms, chained commands (take key and wallet, north then look), pronouns and a second object (put the disk in the drive), all with zero latency. Players can give orders to characters (robot, go east), type numbers (turn dial to 4) and say or answer things in quotes (answer “a well”);
  • an optional LLM on a short leash. Input the parser can’t handle goes to a small server that asks Gemini which of your verbs and IDs it means. The reply is reduced to a verb plus identifiers, so the model never writes the story, and the key stays on the server.

Load a story file. Z-machine games (versions 3, 4, 5 and 8) run unmodified in the same terminal, through ifvms, the interpreter inside Parchment. SAVE and RESTORE work, every turn autosaves, and the status line shows in the header. Zork I, II and III ship with the demo; Microsoft released them under the MIT License in 2025. Type LOAD at the menu to play your own story files, which stay in your browser.

Or both at once. The demo includes Zork I rebuilt as a native world, checked line by line against the original story file: it’s how the engine proves it can carry an Infocom-class game (Porting Zork).

Both kinds sit side by side as cartridges. With more than one, the terminal opens on a menu; with one, it boots straight in.

The terminal is the point. Power-on sequence, scanlines, phosphor bloom and decay, flicker, a block cursor, and a typewriter that changes pace with the scene. All CSS, no canvas.

Built with Brass Lantern

Office Space: The Text Adventure is a full-length game on this engine: four chapters from a very bad Monday at Initech to a field, a baseball bat and a printer that has it coming. It runs with the intent server, so you can type like a person.

Use it as a library

Brass Lantern ships as four npm packages: @brass-lantern/engine (worlds, parser, turn loop, Z-machine runtime), @brass-lantern/vue (the CRT terminal, themes and mountGame), @brass-lantern/server (the intent server) and @brass-lantern/mcp (a local MCP server that lets coding agents audit and play your worlds). Put a game in your own app:

npm i @brass-lantern/engine @brass-lantern/vue vue pinia
import { mountGame } from '@brass-lantern/vue';
import '@brass-lantern/vue/style.css';
import { tutorial } from '@brass-lantern/engine/worlds';

mountGame('#app', {
  cartridges: [{ kind: 'world', id: 'snack-attack', title: 'SNACK ATTACK', world: tutorial }],
  storagePrefix: 'my-game',
});

(Under TypeScript 6 the .css import needs vite/client types or a declare module '*.css';.) The game fills #app, so give it a size (html, body, #app { height: 100%; margin: 0; overflow: hidden; } for a full-screen game); the stylesheet styles nothing else on the page. The terminal comes in five themes (amber and green CRT, and plain light and dark), and the engine also runs headless in Node. Using the library covers all of it. This repo is an npm-workspaces monorepo: packages/ holds the libraries and apps/site is the demo.

Quick start

git clone https://github.com/mrballistic/brass-lantern.git
cd brass-lantern
npm install
npm run dev            # http://localhost:5173

You’ll get the cartridge menu: Snack Attack, a three-room tutorial world, Zork I, II and III, and Zork I rebuilt natively on the engine. What it offers is set in apps/site/src/app.config.ts:

export const cartridges: Cartridge[] = [
  { kind: 'world', id: 'snack-attack', title: 'SNACK ATTACK', world: tutorial },
  { kind: 'zcode', id: 'zork1', title: 'ZORK I', story: 'stories/zork1.z3', format: 'Z-machine v3' },
  { kind: 'zcode', id: 'zork2', title: 'ZORK II', story: 'stories/zork2.z3', format: 'Z-machine v3' },
  { kind: 'zcode', id: 'zork3', title: 'ZORK III', story: 'stories/zork3.z3', format: 'Z-machine v3' },
  { kind: 'world', id: 'zork1-native', title: 'ZORK I · NATIVE', world: zork1 },
];
  • To make your own game, write a world (the bundled ones are in packages/engine/src/worlds/) and add it as a cartridge. Building worlds walks through it, from a two-room game up, with recipes for containers, darkness, timers and endings.
  • To add a story file, drop it in apps/site/public/stories/ and add a zcode entry. See Playing story files.

For loose phrasing in native worlds, run the intent server too (guide):

npm install                           # at the repo root
cd packages/server && cp .env.example .env    # add GEMINI_KEY
npm run dev

Docs

They live in docs/; npm run docs:dev serves them locally.

Stack

Vue 3, TypeScript, Pinia and Vite in the browser; ifvms and glkapi.js for story files; Node 24 or later and Express for the optional intent server; Vitest throughout. Saves stay in the browser’s localStorage, and analytics run only if you configure them, and then only with the player’s consent. See CONTRIBUTING.md to help, and SECURITY.md to report a problem.

License

MIT. Brass Lantern isn’t affiliated with any historical text-adventure publisher, though it owes them everything.

The Zork story files, ifvms and glkapi.js are included under their own MIT licenses; see THIRD_PARTY_NOTICES.md.

BuyMeACoffee

About

A small engine for classic parser text adventures: a CRT terminal in the browser, worlds as data, and an optional LLM intent parser.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages