Sharpee
Chord / Getting Started / What is Chord?

What is Chord?

Chord is a modeling language for parser interactive fiction. You describe the world of your story as a set of plain facts — this room exists, it is dark while the player carries the cloak, this exit leads west — and the compiler checks those facts before anyone plays. A story is one .story file. There is no project scaffold, no package manifest, and no build configuration.

What a story looks like

create the Foyer Bar
  a room, dark while the player has the velvet cloak
  aka bar

  The bar, much rougher than you'd have guessed after the opulence of
  the foyer to the north, is completely empty.

  after the player entering while in-darkness
    phrase stumble
    first time
      change the message to trampled
  end after

That is the whole definition of a room: what it is, when it is dark, what it is called, how it reads, and what happens the first time you stumble into it in the dark. The description is simply the paragraph written inside the block.

How text is emitted

Everything the player reads comes from one of four places.

Descriptions. A bare paragraph inside a create block is that thing's description. Nothing prints it explicitly: the player sees a room's description on entering or looking, and a thing's on examining it. See Prose, paragraphs, and markers.

Phrases. A phrase is a piece of text with a name. The story defines the text once, and a line that names it prints it at that moment. phrase stumble in the room above prints the text called stumble, which the same file supplies:

define phrases en-US
  stumble:
    Blundering around in the dark isn't a good idea!

Other lines name a phrase too: refuse <name> stops the player's action and prints the phrase as the reason, a blocked exit names the phrase it answers with, and win <name> or lose <name> ends the story on one. What a character says is a phrase as well: each row of a conversation table holds ordinary statements, and a phrase line among them is the reply. Examples often show the line and leave the definition out; the name stands for words the story supplies. A phrase used in one place can be written right there instead, as prose indented under the phrase line. define phrases is the plain form above; define phrase gives a phrase variants that cycle or vary at random.

Markers. A {name} inside prose splices the phrase of that name into the sentence, so a description can change from one visit to the next.

Standard messages. The platform answers the ordinary actions itself: "Taken.", "You can't go that way." A story writes nothing to get these. To reword one, an override message block replaces it for the whole story, and a phrase <name>: line in a create block replaces a phrase for that one thing. See Per-entity phrase overrides.

"Modeling language" is the important part

Chord is deliberately not a general-purpose programming language. It has no user-defined functions, no arithmetic expression language, and no imperative control flow. Every line is a statement about the world or about what happens in response to play.

That constraint is what buys the checking. Because the velvet cloak is a declared thing rather than a string, the compiler knows when you misspell it. Because in-darkness is a named condition, the compiler knows when you test a state nothing can ever produce. Names, states, and conversation topics are all resolved at compile time, so the class of bug where a story is quietly broken in a room the author never revisited is a compile error instead.

The trade is real and worth stating plainly: a general-purpose language would let you write anything, and Chord will occasionally tell you that the thing you want is not expressible as a fact about the world. When that happens you can drop to Sharpee, the TypeScript platform underneath, without leaving the story.

What is in the language

  • Things and rooms — create the X, composed from kinds, traits, and settings rather than a class hierarchy
  • Prose — descriptions are paragraphs, not string literals; blank lines are paragraph breaks
  • Phrases — named text, defined once and printed by a phrase <name> line, with variants that cycle or vary at random
  • Exits — declared on the room, including blocked exits with their own refusal message
  • Named conditions — give a world state a name once, then read it as English wherever it is tested
  • Event clauses — after the player entering while in-darkness, with ordinal forms like first time and third time
  • People and conversation — topics, patrols, and scheduled behavior
  • Opt-in systems — a use line enables scoring with its rank ladder, hunger, and other subsystems, and only then does their vocabulary exist

The language is line-oriented and structured by indentation. Blocks open with a header line and close at a dedent or an explicit end. Indentation is spaces; a tab is an error.

Getting it

Most authors use Chord Writer, the macOS application: it carries the whole toolchain, highlights as you type, shows compiler problems live in a panel, and builds a playable browser version in one step. No terminal required.

If you would rather work from a terminal, the CLI installs from npm — see Install.

Where to go next

If you want toGo to
Write your first storyGetting started
Learn the language properlyThe world
Copy a working patternCookbook
Look up exact syntaxGrammar reference
See what runs underneathWhat is Sharpee?
Just play something firstPlay