Writing Text Adventures in Twine

2017-08-24 16:43:26 by KungFuSpaceBarbarian
Updated

I just finished my 4th Crypt Shyfter game in Twine and I wanted to share some of the things I’ve learned over the last few months.

First of all, what the hell is a text adventure? If you haven’t played Crypt Shyfter, a text adventure (sometimes called Interactive Fiction) is a game made purely out of text.

The first computer games were text adventures, since they could easily be played on any computer- graphics could be demanding on a PC without all the right ports and gizmos, but displaying text was no problem.

Text adventures are like Choose Your Own Adventure books, but with a little more sophistication. The games can track variables such as health, inventory items, stats, dice rolls, places you’ve visited, what you’re wearing, who you’re romancing, or anything else you can think of.

Twine makes writing a text adventure super easy- and Twine is free!

I’ve been using Twine because I’m not a programmer. I like to tell stories, but I don’t know much about programming. Twine is the best way for me to make a fun adventure game without needing to know anything about programming.

Another really cool thing about text adventures is that even though there are no graphics, you can still “see” what’s going on in your imagination, just like when you’re reading a book. Only difference is in a text adventure, YOU get to be the hero who does badass stuff, instead of having to read about someone else do cool things in a book.

I also don’t need to spend millions of dollars to render dragons and NPCs and other monsters, ships, castles, volcanos, or other exotic locations because everything is contained in text! When I write about how there is a big beefy minotaur with a bloody axe standing in front of you, you can see that in your head without me needing to draw it.

Do we see the same big beefy minotaur in our minds? Maybe. Maybe not. Maybe your minotaur has black fur and mine has brown fur. Maybe your minotaur has a nose ring and mine has a shaggy mohawk and a skull on his belt.

The cool thing is, we all get to see our ideal version of a minotaur! Remember the 3rd Harry Potter movie with that werewolf that looked like… I don’t know… a hairless monkey or something? How freaking lame was that?

If I put crappy art in my game, you’d play it and be like “Man, this game SUCKS! That werewolf looks like poop!” Even if the game story was good, you’d ditch the game because the graphics are awful.

But since it’s all text, when you read about the werewolf, you see YOUR werewolf in your head- the biggest, hairiest, most badass werewolf of all time, with huge rippling muscles, razor sharp claws, and fangs dripping with blood.

So much more awesome than a crappy werewolf designed by some random guy.

Anyway, that’s what a text adventure is and why I make text adventures instead of other kinds of games. (Don’t get me wrong, all my favorite games have graphics- Jade Empire, KOTOR, Pokemon, Halo, etc. It’s just that if I tried to make a game like that, they’d turn out really bad.)

So how can you make a text game in Twine? First log on the Twine website and start a new game. You’ll be presented with a passage labelled “Start.”

And then…

Start writing! If you want to include a link, or add choices, it’s as simple as adding square brackets. For example:

You come to a split in the road. Do you want to go left or right?

[[Go left|left1]]

[[Go right|right1]]

 

That’s it! Twine will automatically create two new passages, one labelled “left1” and another labelled “right1.” You can name passages whatever you want. [[Go left|fuckaduck]] The first half of the link shows the text the reader will see, and the second half of the link represents the passage name. Use the bar symbol | to divide the link between text and passage name.

Now, for simple games, that’s all you need to do. Just keep making links until your player reaches the end. But if you want to get a little more complex, you’ll need to add in a bit of code.

Let’s say you want to give the player a choice between weapons. Do you want a sword or a spear? Create your [[Sword|sword]] and [[Spear|spear]] links. When a link is clicked, add this code to the passage:

<<set $weapon = “Sword”>>\

Typing a $ symbol followed by a word creates a variable. You can use variables in a number of different ways throughout your game.

In a future passage, you can write: “You stab the goblin with your $weapon.” If the player chose a spear, this will show up as “You stab the goblin with your spear.” The game will track this variable for the rest of the game unless you change it- maybe a player will ditch the spear in favor of a magic fire sword, in which case you just change the variable:

<<set $weapon = “Magic Fire Sword”>>\

Aside from variables, you can also create “if/then” statements. If a character comes to a locked door, they can only open it with the gold key. If they don’t have the gold key, they need to go back and find it. That would look something like this:

<<if $goldkey == “true”>>\

You unlock the door with the gold key.

[[Continue|walkthrudoor]]

<<else>>\

You need the gold key to unlock this door.

[[Continue|returntohallway]]<</if>>

 

Now what if we want our player to be able to track their items? You’ve got a Magic Fire Sword and a gold key, but what if you forget? Time to create an inventory!

To build an inventory, add this code to the first passage of your game:

<<set $inventory=  []>>\

This creates an array in the game, which you can add items to. To add an item to your inventory, add this code:

<<set $inventory.push("Pizza")>>\

To remove an item from your inventory, add this code:

<<set $inventory.delete("Pizza")>>\

 

So these lines add and remove items, but how can your player view that inventory? Create a passage labelled inventory and add this code:

<<print $inventory.join("\n")>>

<<return "Back">>

 

What this does is display all items in the inventory as a list. It will look like this:

Magic Fire Sword

Gold Key

Pizza

 

At the bottom, there is a code that allows the player to return to the previous passage. The link says “Back” and the player can click that to return to the game when they’re done checking the inventory.

There are lots of other fun things you can do with codes and variables, but for now I’ll let you play around with these and see what you come up with. There are tons of tutorials online, and that’s how I learned to make Twine games. I’d also recommend checking out Writing Interactive Fiction With Twine, which is the book that got me started making Twine games to begin with.

If you start making your own Twine game and run into any issues, shoot me a message and I can help you out with some of the codes!

Just as a heads up, there are a few versions of Twine. I’m using Twine 2, and the format I’m using is called Sugarcube. If you write in Harlowe or another story format, the codes will be different, so keep that in mind! I may not be able to help if you’re using a different story format.

I hope this helped, and if you decide to make a text adventure please share it with me when you’re done!

~kfsb

 


Comments

You must be logged in to comment on this post.


BenjaminTibbettsBenjaminTibbetts

2017-08-25 11:00:48

Great article, interesting to learn a little more about Twine. Thank you. :)

KungFuSpaceBarbarian responds:

hope it helps if you ever decide to make a text game! :D


TroisnyxTroisnyx

2017-08-25 13:10:09

I take it you haven't.... uh, figured out Howler yet.
Are you planning to introduce a spell system soon, for those who use it?

(Updated ) KungFuSpaceBarbarian responds:

I'm actually going to be using Renpy for my next game so I will include art and music haha :D

Renpy has those features built right in whereas twine needs you to code it all yourself, and you risk links breaking because everything is linked from an external site, so adding music will be much easier!


GabeMalkGabeMalk

2017-08-26 01:25:24

THANK YOU SO MUCH! This helps a lot!

KungFuSpaceBarbarian responds:

Sweet :D let me know if you need help with any codes!