As you played/read Depression Quest, you noticed that one of its most effective techniques was to limit the character’s choices while making you aware of what choices were not available. A common question was whether earlier choices affected the choices available later in the story. While I have not seen the back end of Depression Quest and I don’t know exactly what tools the creator was using, this Twine Time tutorial will walk you through how to mark up text so that it is struck out (achieving the effect of taking away a choice) and how to make the appearance of choices conditional on a character’s prior choices.
NB: Bolded words are words that are core to coding and/or computational thinking. You will see them again.
If you are feeling creative, feel free to come up with your own story. In order to practice using the variable and conditional macros (a small piece of code that produces a certain effect in Twine), you’ll need to have a story that has some choices with consequences. You can also just copy & paste the example I came up with spelled out in the steps below.
Go to twinery.org and start a new Twine story. I titled the example used below “Conditional Love: A Valentine’s Day Story”
Title the first passage Start or Beginning or something that makes sense to you.
Introduce a choice to be made and include links to two additional passages, each standing for a choice.
Remember: the syntax for linking to a passage is [[narrative text|name-of-linked-passage]]
Example:
Cassidy has a crush on Cameron. Cameron likes cookies. Should Cassidy get Cameron a [[rose|rose]] or a [[cookie|cookie]] for Valentine's Day?
This will create two new passages called rose and cookie.
Now, how will we mark that the player has made one of the choices? We will set a variable, which is basically an empty container that we can fill with a value, a word (known as a string), or a true/false state (known as a Boolean). For this example, we will use a string.
The syntax for setting a variable with a string input in Twine is:
(set: $variableName to "string") Passage text as normal.
We can set the variable in the relevant passage to mark what gift Cassidy picked out for Cameron, and give a link to the next passage.
So in the rose passage, I would type:
(set: $gift to "rose")Cassidy carefully selects a single, perfect red rose. Cameron is in Cassidy's CS class, so they plan to arrive early to class to [[give|give-gift]] it to them.
In the cookie passage, I would type:
(set: $gift to "cookie") Cassidy selects an artisanal dark chocolate sea salt dusted cookie. Cameron is in Cassidy's CS class, which is right in the middle of the morning so very much an ideal snack time, and Cassidy plans to arrive early to [[give|give-gift]] it to them.
Now there has been additional passage for gift giving created, but just one. I can have characters who have made different choices see different things using the conditional macros (if:) and (else:)
(if:) checks to see if a condition has been met and what to display if so. Its syntax for a string variable is:
(if: $variableName is "name")[Passage that you will display in that case.]
(else:) gives what to display if the condition has not been met. Its syntax is:
(else:)[Passage that you will display in that case.]
Notice that you don’t have to specify what else it might be. If it’s anything other than what you’ve specified, it’s else. (What if there are more than two choices? Then you can use else-if, which looks like (elseif:) in Twine. That would also require a specific condition, and can only be used after an if has been established.)
In the give-gift passage, I would type:
(if: $gift is "cookie")[Cassidy gives Cameron the cookie right before class as planned. Cameron looks at Cassidy with gratitude and a new gleam in their eyes. Cassidy may be overthinking it, but it seems like Cameron blushes a little, in a good way.]
(else:)[Cassidy gives Cameron the rose right before class as planned. Cameron looks really embarassed. They don't make eye contact with Cassidy again that day.]
The [[next day|next-day]], Cassidy and Cameron find themselves walking side by side into the library.
Pause here and do a play through to check if it’s working. If it isn’t, you probably forgot a bracket somewhere.
I have, again, only created one next-day passage, so I’ll also need to use some kind of conditional to show appropriate choices. And while we’re doing that, let’s also experiment with two new ways of altering the passage display: strikethrough formatting and the (link:) macro.
Strikethrough formatting is a kind of mark up, or tagging of text in a way that changes its appearance. The mark up for strikethrough in Twine is:
~~struck through text~~ (those are two tildes, btw)
The (link:) macro is a way of changing the text that appears in the passage without actually changing passages. The (link:) syntax is:
(link: "passage text you want to appear linked")[what you want the new text to say]
To use these in next-day, I would type the following:
(if: $gift is "cookie")[Hey, Cameron says. Thanks for the cookie. You're welcome, Cassidy says casually. We should get coffee some time maybe, says Cameron.
(link: "The end.") ["Cassidy + Cameron 4ever."]]
(else:)[Cameron looks down and hurries into the library.
~~Strike up a conversation with Cameron.~~
[[Oh well.|ending]] ]
After you’ve entered this, do a play through to see if it works and how. If something’s not working, check those brackets. It matters how many there are and what place they are in.
A couple of things you might now notice:
- There are two broad areas of developing a Twine story: changing what it does (eg using macros to build in interactive dynamics) or changing how it looks (using formatting to convey information).
- Which one of these is more effective? Depends on the story you want to tell.
- Also depends on what interests you more–fussing with appearance or fussing with structure?
There are many more macros (random events, data arrays) and many more formatting options (images, background, font, font color, etc). For your first project, you probably won’t have time to develop both areas. Significant development in either area is sufficient to complete the project with an A grade.
Acknowledgements:
Tutorial developed in consultation with Melissa Ford’s Writing Interactive Fiction With Twine
