Create random passages

Hi gang,
I have a really basic understanding of twine and no coding experience but I get on just fine building stories. I have a VR project in development and I am building out the story beats in twine. A part of the experience is that when someone selects an item it will play one of three randomised audio bites. I want to mimic this in Twine with randomised text events. I found some forum posts that discussed this but it just goes over my head.

An example of this would be from these options when one is selected it will jump to one of three random pieces of text per option. Any help would be really appreciated.

[[look out window to your left]] goes to…
Random text 1
Random text 2
Random text 3

[[look at woman]] goes to…
Random text 1
Random text 2
Random text 3

[[Look at ticket inspector]] goes to…
Random text 1
Random text 2
Random text 3

[[Look out window to your right]] goes to…
Random text 1
Random text 2
Random text 3

1 Like

Sorry just to say i’m using Twine online right now. Standard format.

Use (link-goto:) and make the destination (either:).


At the Window

You are sitting at the window.
(link-goto: “Look out the window.”, (either: “A car”, “A cat”, “A can”))

A car

A car drives by.

A cat

A cat walks by.

A can

A can rolls by.

Note: This answer is for the default story format, Harlowe 3.1.0

1 Like

The TWEE Notation form of this example would look something like…

:: StoryTitle

:: At the Window
You are sitting at the window.
(link-goto: “Look out the window.”, (either: “A car”, “A cat”, “A can”))

:: A car
A car drives by.

:: A cat
A cat walks by.

:: A can
A can rolls by.

Just to be clear, by “standard format” do you mean you’re using the Harlowe story format?

Because there isn’t really a “standard format”.

I think this means whatever gives you when you click “+Story”. That’s Harlowe 3.1.0.

@Greyelf – does let you import or export TWEE?

Yes using Harlowe 3.1.0

Okay so… I would just paste this code into a new passage? Or is there more too it than that?

The TWEE notation is like this:

:: Passage Name
Passage text to display.

So if you look at Greyelf’s code, you can see how the different passages are set up. You’ll have to manually make all of those if you’re using the online editor.

Please forgive me if I’m explaining the obvious: it’s just that I know from experience how frustrating it can be when everyone skips from step One to step Five because they’ve done it so often that steps Two to Four seem obvious.

Just to start from the beginning: what you’re looking at is a page with a square grid (a bit like graph paper) for the background, and boxes joined together with arrows (or just a single box if you’ve opened a fresh story.) Correct?

Unless you’ve chosen a different format, you’re using the Harlowe format. Harlowe 3.1.0 to be precise, and it’s important to tell people the version because the available features vary between versions.

Each of those boxes is what Twine calls a passage. A passage has a header (shown in bold) which is how the system distinguishes one passage one from another, and a body, which contains the text which the player sees. In Harlowe, headers are not shown to the player (so you don’t have to worry about them providing spoilers, for example.)

Here on the forum it’s not very easy to describe the visual metaphors that the GUI uses, so we use Twee notation instead. (Twee notation is a way of writing Twine games using only a text editor.)

This is what a Passage looks like in Twee notation:

::Passage Header
This is the body of this passage. Everything written here, up until the next header will be rendered to screen.

::Next Passage
This is a different passage.

So if someone on the forum gives examples, all you have to do is add a new passage in the GUI for each passage in the example and copy/paste the passage header/s and passage body/ies in the appropriate place.

So, to finally get to your question!

If you want to display a bit of text as a random response to the player clicking on a link, then you need to use a macro, in this case the “either” macro. Macros are just pre-written bits of code that let you plug in the bits of information relevant to your game.

So let’s imagine the player is in the kitchen and you want to let them look out of the window.

The diswasher burbles happily to itself as you sit down with a mug of coffee.

[[look out the window]]

::look out the window
You look out of the window. (either: 
	"A cat slinks past.",
	"The washing flaps in the breeze.",
	"A jet screeches by overhead.",
	"Jenny is playing on the swings.",

[[stop looking out of the window->kitchen]]

Macros are fussy about punctuation, but the layout is purely to make it easier for humans to read. You could put it all on one line if you wanted. But in Harlowe, for a macro to work, you must:

  • put the name of the macro immediately after the opening parenthesis, followed by a colon,
  • put the different responses in quote marks, and separate each response with a comma,
  • end the macro with a closing parenthesis.

Notice the last link. This will show the text “stop looking out of the window” as the link, but will actually link back to the “kitchen” passage. It’s true that in this situation the player could get back to the kitchen by clicking on the curly “undo” arrow in the sidebar, but beware of this. If the “looking out of the window” passage ran some code to, say, start a saucepan boiling over, then the player using the “undo” arrow would also undo running that code, so the saucepan would never boil over!

You’ll also notice that there’s no space between “stop looking out of the window” and “kitchen.” That’s because to Twine, the passages “kitchen” and " kitchen" (note the space at the front) are different. This is a very easy way to introduce bugs into your game so it’s worth being careful over.

Anyway, hope this has been helpful; there’s a full list of macros in the Harlowe Manual.


The Twine 2.x application as is doesn’t support either importing or exporting TWEE files, however you do have the following options:

  1. Install a third-party Proofing Format the supports the outputting of TWEE Notation.
    One example of such is Chapel’s Poof

  2. Use a TWEE compiler that supports the transforming of Twine 2.x project/archive/story HTML files into a TWEE file, and back again. One example of such is TheMaxExile’s TweeGo command line compiler.

1 Like

While it is true that the Twine 2.x application defaults to the Harlowe story format, unless the end-user has manually changed the application’s default settings. Which series and versions of Harlowe is included with the application, and thus which version of Harlowe the application will default to depends on which version of the Twine 2.x application the end-user is using.

1 Like

It’s poof you philestine!

:upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face: :upside_down_face:

I have no idea what you are talking about (especially after I edited that post), you may need glasses (or thicker ones if you are already wearing some) :smile:

1 Like

Thank you so much for this thorough answer, @Dizzydonut! As a new user of twine, I am grateful for the efficient explanations on several things that puzzled me!

You’re welcome. Lots of people have given me help (and still are, come to that) so I’m happy to continue the tradition.

1 Like

That’s the attitude that keeps the internet worth surfing. :slightly_smiling_face:

1 Like