Who Twine suits#
Twine suits a story told through links in the text: a choose-your-path tale, a poem that branches, a game of small choices. Each page the reader sees is one passage. If you want the reader to type commands, Inform 7 fits better; for long branching conversations, ink is built for that.
Start a Twine story#
- Open Create a Story and sign in.
- Under Create from scratch, choose Twine.
- To write here, give the story a title under Start writing here and press Start writing. A new story opens in the editor: the twee source on one side, the story playing on the other.
- To bring in a story from the Twine app, choose Upload your Twine HTML and upload the file you made with Build → Publish to File in Twine.
A story you start here uses Harlowe 3.3.9, Twine's default story format. A story you upload keeps the format it was published with (Harlowe, SugarCube, Snowman or Chapbook), and the editor leaves that format's engine as it is when you change the passages. The story is private to you until you publish it.
Your first story#
The editor's source starts with the passages that hold the story's settings: :: StoryData, :: StoryTitle, and :: StoryStylesheet or :: StoryJavaScript when the story has a stylesheet or a script. Keep those as they are, and replace every passage under them with these:
:: Start
(set: $coins to 3)
(set: $hasLantern to false)
Lanterns sway over the stalls of the night market. You have $coins coins.
[[Buy a paper lantern->Lantern Stall]]
[[Walk down to the river->River]]
:: Lantern Stall
(set: $coins to $coins - 1)
(set: $hasLantern to true)
The seller folds a lantern from red paper. You have $coins coins left.
[[Walk down to the river->River]]
:: River
(if: $hasLantern is true)[You light the lantern and set it on the water. It drifts toward the bridge.]
(else:)[The water runs black under the bridge. You wish you had a light.]
[[Start again->Start]]The editor saves a moment after you stop typing, and the preview reloads with the new version. Click Buy a paper lantern, then Walk down to the river, and the river passage shows the lantern line.
The syntax#
The source has two layers. Twee marks where each passage starts. Inside a passage, the story format reads links, variables and macros. The examples below are Harlowe, the format of stories started here.
Passages#
A passage starts with a line beginning :: and the passage's name. Tags go in square brackets after the name. Everything up to the next :: line is the passage's text.
:: The Bridge [night outdoors]
Water slides under the stones.Two passages are special. StoryTitle holds the story's name, and StoryData holds its settings, including which passage the story starts on. When no start is set, the story starts on the passage named Start. A passage tagged [stylesheet] holds the story's CSS and one tagged [script] its JavaScript. Each passage name must be used once.
See the Twee 3 specification and the Twine reference's basic concepts.
Links#
A link is text inside double square brackets. The arrow points at the passage the link goes to. With no arrow, the text is the passage's name.
[[Cross the bridge->The Bridge]]
[[The Bridge<-Cross the bridge]]
[[The Bridge]]All three go to the passage named The Bridge. The name must match the passage's name letter for letter.
See Link markup in the Harlowe manual.
Variables#
A variable's name starts with $. (set:) gives it a value, and writing its name in the text prints it. A variable whose name starts with _ lasts only for the passage or hook where it is set.
(set: $name to "Ana")
(set: $coins to $coins + 2)
(set: _price to 4)
$name counts her coins: $coins.A $ variable you never set reads as 0. Names are case-sensitive, so $Coins and $coins are two variables.
See Variable markup and (set:) in the Harlowe manual.
Hooks, if and else#
A hook is text in single square brackets. A macro placed right before a hook changes it. (if:) shows its hook only when the condition is true. (else-if:) and (else:) follow it and show their hooks when the ones before were hidden.
(if: $coins is 0)[Your pockets are empty.]
(else-if: $coins is 1)[One coin left.]
(else:)[You have $coins coins.]See Hook markup, (if:), (else-if:) and (else:) in the Harlowe manual.
Links that reveal text#
(link:) turns a hook into a link. When the reader clicks it, the link disappears and the hook's text shows in its place, without leaving the passage.
(link: "Open the letter")[It is blank, except for a drawing of a key.]See (link:) and (link-goto:) in the Harlowe manual.
Random text, visits and reuse#
(either:) picks one of its values at random. (visited:) is true when the reader has been to a passage. (display:) shows another passage's text in this one, and (go-to:) moves the reader to a passage right away.
A (either: "cold", "damp", "still") wind comes off the water.
(if: (visited: "The Bridge"))[You have crossed here before.]
(display: "Status Bar")See (either:), (visited:), (display:) and (go-to:) in the Harlowe manual.
Other story formats#
An uploaded story keeps its own format, and each format writes variables and conditions its own way. Twee passages work the same in all four. For each format's syntax, read its own manual: Harlowe, SugarCube, Chapbook and Snowman.
What the editor does for Twine#
The editor shows your twee source on one side and the story playing on the other. Everything below is on the story editor guide too, with each control's place on a phone.
- Saving happens a moment after you stop typing. Each save checks the passages. When the check finds an issue, the issues list under the source says what it is, and an issue that names a line is a key that jumps to it. The editor still saves your text, and the story plays as it last passed the check until you fix the issue.
- The preview runs your story on its own format's engine, closed off from the rest of the page. It reloads after each save that passes the check. Restart plays it from the start.
- Story map lists every passage with its tags, the start of its text and the links leading out of it. A passage with no links out is marked as a dead end or an ending. The map shows the story; you change it in the source.
- Replace HTML takes a new file published from the Twine app and replaces every passage with it. It asks first; the cover, credits, reviews and play counts stay.
- Variables lists the variables your story uses and lets you tie each one to a faction, an item, a relationship, a quest flag or a stat in wilds.ai. This leaves your passages as they are.
- Enhancements gives each passage a scene picture (a link, or one drawn from a prompt) and an ambient mood. The picture shows over the story when the reader reaches the passage.
- AI co-writer, Suggestions and Lorebook help you write. Every suggestion the AI writes is checked with your passages before you see it, and nothing changes until you press Accept. Each AI action costs 1 credit on the free plan and 2 credits on a paid plan; a suggestion that does not pass the check is not charged. See the AI tools.
- Playtest opens the story on its play page in a new tab.
- Details holds the title, summary, tags, content rating, cover, audio, credits and publishing settings.
- Publish records a version of the story. Who can play it (Private, Unlisted or Public) is set under Details, in Publishing.
- Guide and Syntax, in the top bar, open this guide and its syntax section.
Fix common issues#
The first four come from the check the editor runs on each save; they show in the issues list under the source. The other six come from Harlowe and show inside the preview, where the passage would be. The words in quotes are taken from the message.
Two passages with the same name#
"Duplicate passage name:". Each :: line names a passage, and a name can be used once. Rename one of them, and update the links that point to it.
The start passage is missing#
"Start passage ... does not exist." The story starts on the passage StoryData names, or on Start when it names none. Restore that passage, or rename the passage you want first.
No passages at all#
"The story has no passages." The source needs at least one :: line besides StoryTitle and StoryData.
The source could not be read#
"Twee did not parse:". A passage header is broken: check that each one starts at the beginning of a line with ::, and that its tags in [ ] and settings in { } are closed.
A link that cannot be clicked#
A link to a passage that does not exist shows as a red link that cannot be clicked. Check the passage name after the arrow. It must match the :: line letter for letter, capitals included.
Going to or showing a passage that does not exist#
"I can't (go-to:) to the passage ... because it doesn't exist." or "I can't (display:) the passage ... because it doesn't exist." The name in quotes inside the macro does not match a passage. Fix the spelling or add the passage.
A macro Harlowe does not know#
"I can't run the macro ... because it doesn't exist." Check the macro's name against the Harlowe manual: it is the word before the colon, as in (set:).
else with nothing before it#
"There's nothing before this to do (else:) with." (else:) must follow an (if:) or (else-if:) with its hook. Move it right after that hook.
A temporary variable used in the wrong place#
"There isn't a temp variable named _... in this place." A _ variable lasts only for the passage or hook where it was set. Use a $ variable to carry a value between passages.
Something Harlowe cannot read inside a macro#
"isn't valid Harlowe syntax for the inside of a macro call." Look for a typo, a missing comma between values, or a quote that is not closed. Harlowe 3.3 does not take JavaScript inside a macro.
The Twine and Harlowe manuals#
The Twine reference at twinery.org/reference covers stories, passages and story formats. The Harlowe manual at twine2.neocities.org lists every macro with examples; it is written for Harlowe 3.3.8, and the editor runs 3.3.9. Twine's Cookbook has worked examples for each format.