Home > Store

Writing Interactive Fiction with Twine

Register your product to gain access to bonus material or receive a coupon.

Writing Interactive Fiction with Twine

eBook (Watermarked)

  • Your Price: $15.99
  • List Price: $19.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.


  • Copyright 2016
  • Dimensions: 7" x 9-1/8"
  • Pages: 432
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-430309-1
  • ISBN-13: 978-0-13-430309-3

Writing Interactive Fiction with Twine: Play Inside a Story

If you’ve ever dreamed about walking through the pages of a book, fighting dragons, or exploring planets then Twine is for you. This interactive fiction program enables you to create computer games where worlds are constructed out of words and simple scripts can allow the player to pick up or drop objects, use items collected in the game to solve puzzles, or track injury in battle by reducing hit points. If you’ve clicked your way through 80 Days, trekked through the underground Zork kingdom, or attempted to save an astronaut with Lifeline, you’re already familiar with interactive fiction. If not, get ready to have your imagination stretched as you learn how to direct a story path.

The best part about interactive fiction stories is that they are simple to make and can serve as a gateway into the world of coding for the nonprogrammer or new programmer.

You’ll find expert advice on everything from creating vivid characters to building settings that come alive. Ford’s easy writing prompts help you get started, so you’ll never face a blank screen. Her “Try It Out” exercises go way beyond the basics, helping you bring personal creativity and passion to every story you create!

  • Get familiar with the popular Twine scripting program
  • Learn how to design puzzles
  • Build your own role-playing game with stat systems
  • Maintain an inventory of objects
  • Learn game design and writing basics
  • Change the look of your story using CSS and HTML
  • Discover where you can upload your finished games and find players

Sample Content

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

Table of Contents

Foreword xvi

Introduction to Interactive Fiction 1

Chapter 1 The Nuts and Bolts: Getting Started with Twine 5

Installing Twine 5

Starting Your First Story 6

Saving in Twine 9

Navigating Twine Menus 9

    Getting to Know the Stories Screen 9

    Getting to Know the Blue Grid Screen 9

    Getting to Know the Hover Menu 10

Chapter 2 Using Choice to Create Agency 13

Designing Agency 14

    Providing Clues 17

    Crafting Meaning 18

    World-Building with Optional Details 19

    Using Choice to Affect Pacing 21

Imagining Different Choices 22

    Giving Preference Choices 22

    Giving Value Choices 22

    Giving Adventure Choices 22

    Giving Ethical Choices 22

    Giving Cause/Effect Choices 22

    Giving Exploratory Choices 23

    Giving Obtainable Choices 23

    Giving Directional Choices 23

Plotting Your Story’s Choices 23

Handling Endings 25

    Using the Fan Story Shape 25

    Using the Hourglass Story Shape 25

    Delaying Branching 27

Creating Another Type of External Link 27

Chapter 3 Creating a Vivid Setting 29

Understanding the Importance of Setting 29

    Creating Setting from Prompts 30

    Adding Descriptions with (link:) 31

    Repeating Text with (display:) 32

Setting Tips and Exercises 35

    Writing What You Know 35

    Being the Player’s Eyes 36

    Considering What a Character Would Notice 36

    Combining Motion with Surroundings 37

    Using Your Other Senses 38

    Considering the Mood of a Place 38

    Drawing the Player’s Attention 40

    Using Descriptive Words 40

    Distinguishing Static and Dynamic Settings 42

Building a Map-Based Game 43

Creating a Maze 46

Chapter 4 Designing Puzzles 49

Finding Puzzle Ideas 50

    Finding Puzzles in Everyday Life 50

    Making Your Puzzles Matter 51

Building Puzzles in Twine 52

    Finding the Starting Point and End Goal 52

    Adding Layers to Your Puzzle 54

    Finishing the Puzzle 58

Building Other Types of Puzzles 58

Using Macros and Hooks 59

Using Named Hooks 62

Chapter 5 Building Objects with Variables 67

Using Objects in Interactive Fiction 67

Building Interactive Objects with Variables 68

    Creating a Variable 68

    Changing a Value 69

    Using Strings 70

    Using Boolean Values 70

    Using Variables in Passages 71

Building Conditional Statements 77

    Adding a Conditional Statement 78

    Adding More Than One Condition 81

    Keeping Track of the Player 83

Setting Up Types of Quests 86

    Writing Search Quests 86

    Writing Fetch Quests 87

    Writing Drop-off Quests 87

    Writing End Quests 87

    Writing Rescue Quests 88

    Writing Escape Quests 88

    Writing Transformative Quests 89

    Writing Creation Quests 89

Chapter 6 Stasis, Catalyst, and Climax: Understanding Story Arc 91

Drawing a Story Arc 91

Understanding Time and Pacing 93

Making a Game with Story Arc 94

    Opening a Game in Stasis 94

    Continuing to the Catalyst 96

    Building to the Climax 97

    Returning Back to Stasis 99

Diagramming the Story 100

Extending Story Arc 102

Counting Turns with the (history:) Macro 103

    Controlling Time with (history:) 104

    Controlling Links with (history:) 105

Chapter 7 Exploring Interactive Fiction Genres 107

Managing Reader Expectations 108

Creating Chance with the (either:) and (random:) Macros 109

    Using the (either:) Macro 109

    Using the (random:) Macro 113

Delving into Genres 115

    Exploring Horror 115

    Exploring Fantasy 116

    Exploring Science Fiction 117

    Exploring Mystery 118

    Exploring Espionage 118

    Exploring Adventure 119

    Exploring Magical Realism 120

    Exploring Historical 120

    Exploring Western 121

    Exploring Nautical 123

    Exploring Fairytale and Folklore 123

    Exploring Mythology 124

    Exploring Realistic Fiction 125

    Exploring Other Genres 125

Understanding Motivations 126

Chapter 8 Constructing Believable Characters 127

Recognizing the Traits of Successful Characters 127

Using the (click:), (mouseover:), and (prompt:) Macros 129

    Using the (click:) Macro 129

    Using the (mouseover:) Macro 132

    Using the (prompt:) Macro 137

Distinquishing Types of Characters 138

Limiting Characters 139

    Creating a Clear Set of Traits 139

    Setting a Goal 142

    Being Vulnerable 143

Deepening Character Building 144

    Assigning Purpose 144

    Providing Exposition 145

    Exploring Relationships 145

Chapter 9 Maintaining an Inventory 147

Managing Inventory with Arrays 148

Using Variables to Work Around Arrays 151

Using the (array:) Macro 154

    Building a Basic Array 154

    Adding Items to an Array 156

    Dropping Items from an Array 158

    Checking Strings in an Array 159

    Checking the Array Size 161

    Limiting the Array Size 161

    Troubleshooting Arrays 162

Using the (count:) Macro 164

Utilizing Literary Techniques 165

    Using Symbolism 166

    Using Allegory 166

    Using Simile 167

    Using Metaphor 167

    Using Analogy 168

    Using Allusion 169

    Using Irony 169

    Using Hyperbole 170

Chapter 10 Achieving Proper Pacing 171

Understanding Plot 172

Setting the Pace with Language 177

    Determining Description Amount 177

    Employing Internal Thoughts 177

    Leaving Information Unknown 177

    Setting the Danger Level 177

    Varying Sentence Length 178

    Regulating Passage Length 178

    Limiting Word Count 178

    Using Sentence Fragments 178

    Moving with Vivid Verbs 179

Utilizing Setter Links 179

Chapter 11 Foreshadowing Important Clues 183

Using the (append:) Macro 184

Using the (prepend:) Macro 187

Foreshadowing Clues 189

    Dropping Direct Clues 189

    Dropping Subtle Clues 190

    Dropping Dream Clues 190

    Dropping Feeling Clues 190

    Dropping Red Herrings 190

Creating a Hint System 191

Including Inside Jokes and Easter Eggs 194

Chapter 12 Making a Role-Playing Game 195

Using the (datamap:) Macro 196

    Adding Values to the Datamap 197

    Removing Values from a Datamap 198

    Using a Datamap for a Stat System 198

Establishing Class 199

    Becoming a Wizard 199

    Becoming a Knight 199

    Becoming a Thief 199

    Becoming a Healer 199

    Becoming an Elf 200

    Becoming a Dwarf 200

    Coding Class Selection 200

Establishing Names 202

Establishing Personal Characteristics 203

    Choosing Gender, Height, and Weight 204

    Troubleshooting User Play Decisions 204

Establishing Traits 206

    Deciding on Traits 207

    Determining Hit Points 207

Making the Next Character 208

Wrapping Up the Opening 210

Limiting an Array 211

Chapter 13 Combat and Consequences in Role-Playing Games 213

Exploring the World 215

    Using Personal Characteristics 215

    Making Consequences 217

    Using Traits 219

    Using Items 220

Battling Monsters 223

    Starting the Fight 224

    Continuing the Fight 227

Solving Puzzles 229

Writing a Conclusion 231

Taking Your Role-Playing Game to the Next Level 231

Breaking Down Game Writing into Manageable Chunks 231

Chapter 14 Wiggling Words: Changing the Text Appearance 233

Changing Fonts 234

    Adding a New Font 234

    Designing Fonts 235

    Picking a Font 236

Changing Text Style 237

    Adding Style 237

    Changing Understanding 238

    Changing Size 239

Changing Text Color 240

Changing Text Transitions 241

Chapter 15 Story Style: Changing the Game Appearance in Harlowe 243

Navigating the Stylesheet 244

    Setting Up Selectors and Declarations 245

    Changing the Background 247

    Changing the Sidebar 248

    Changing the Font 249

    Changing the Links 251

Getting Rid of Whitespace 252

Chapter 16 Adding Images in a New Format 253

Changing Over to SugarCube 254

    Learning a New Macro Format 255

Deciding to Use Images 256

    Knowing Which Image Files You Can Use 256

    Enhancing Understanding with Images 257

    Enhancing Player Mood with Images 257

    Enhancing Game Play with Images 257

Adding Images to a Game 258

    Sizing Images Before Uploading 258

    Writing Image Code in a Passage 258

Using Images Creatively 260

    Making Simple Links 260

    Making Setter Links 262

    Making Mouseover Clues 264

Chapter 17 Setting Up the Pre-Story, Central Story, and Post-Story 267

Learning New Macros 268

    Using the <<set>>, <<unset>>, and <<print>> Macros 268

    Using the <<if>>, <<else>>, and <<elseif>> Macros 270

    Using the <<nobr>> and <<silently>> Macros 273

Designing the Pre-Story 275

    Telling or Not Telling 276

    Working the Backstory into the Game 277

    Including Game Tutorials 278

Designing the Post-Story 279

    Defining the Ending 279

    Moving Beyond Happily Ever After 281

    Making Sequels 282

Chapter 18 Developing a Strong Player Character 283

Using the <<button>>, <<radiobutton>>, and <<checkbox>> Macros 284

    Learning the <<button>> Macro 284

    Learning the <<radiobutton>> Macro 285

    Learning the <<checkbox>> Macro 286

Using the <<textarea>> and <<textbox>> Macros 288

    Learning the <<textarea>> Macro 289

    Learning the <<textbox>> Macro 290

Using the <<click>>, <<append>>, <<prepend>>, <<replace>>, and <<remove>> Macros 291

    Learning the <<click>> Macro 291

    Learning the <<append>> and <<prepend>> Macros 292

    Learning the <<replace>> and <<remove>> Macros 294

Working with Narrative Voice 296

    Setting the Narrator 296

    Being Consistent 297

    Changing the Point of View 298

    Playing for Research 299

Communicating with Non-Player Characters 299

    Handling Dialogue 299

    Using Twine Tricks for Conversation 301

    Conveying Nonverbal Communication 302

    Employing Juxtaposition and Contrast 303

Defining Goals and Assigning Purpose 303

    Creating Blank or Defined Player Characters 303

    Considering Gender 304

    Slipping Into Character 304

Chapter 19 Balancing Pacing and Action 307

Using the either() and random() Functions 308

    Learning the either() Function 309

    Learning the random() Function 310

Using the turns() and visited() Functions 311

    Learning the turns() Function 311

    Learning the visited() Function 313

Using the <<back>> and <<return>> Macros 315

    Learning the <<back>> Macro 315

    Learning the <<return>> Macro 316

Using the <<display>>, <<actions>>, and <<choice>> Macros 317

    Learning the <<display>> and <<actions>> Macros 317

    Learning the <<choice>> Macro 319

Saving Your Game 320

    Using the Save Feature 321

    Retrieving a Saved Game 321

Playing with the Pacing 322

    Speeding Up the Story 322

    Slowing Down the Story 323

    Striking a Pacing Balance 323

Managing Expectations 324

    Highlighting Change 324

    Using the Rule of Three 325

    Distracting the Player with MacGuffins 325

Chapter 20 Keeping Players Engaged 327

Returning to Arrays 328

    Building a New Array 328

    Adding Items to an Array 329

    Dropping Items from an Array 330

    Checking Strings in an Array 332

    Limiting the Array Size 333

    Troubleshooting Arrays 334

Checking Your Inventory 335

    Setting Up an Inventory Passage 335

Understanding Special Passages 337

    Using the StoryMenu Passage 337

    Using the StoryCaption Passage 338

Knowing Your Audience 339

    Aiming for a Niche 339

    Speaking Broadly 340

    Writing for One Person 340

    Deciding on Length 341

    Piquing Interest with a Teaser 341

Recognizing the Three Types of Players 342

    Making Games for Win Seekers 342

    Making Games for Story Seekers 343

    Making Games for Realism Seekers 343

Keeping Players Engaged 344

    Having a Plan 344

    Being Creative 344

    Giving a Purpose 345

    Rewarding Choices 345

    Leaving Them Dreaming 345

Chapter 21 Show, Don’t Tell 347

Learning About Other Formats 349

    Adding New Formats in Twine 349

Utilizing the time() Function and <<timed>> and <<goto>> Macros 350

    Counting Seconds 350

    Building a Timer 352

    Delayed Text 353

Practicing Showing, Not Telling 354

    Problems with Telling 355

    Describing Actions 356

    Drawing Conclusions 357

    Demonstrating Behavior 358

    Transporting the Reader 359

    Trusting the Reader 360

Telling, Not Showing 361

Chapter 22 Story Style: Changing the Game Appearance in SugarCube 363

Navigating the Stylesheet 363

    Reviewing Selectors and Declarations 364

    Changing the Background 367

    Changing the Sidebar 368

    Changing the Font 372

    Changing Links 374

    Creating a Class on the Stylesheet 376

Using HTML in a Passage 378

    Bolding Words 378

    Italicizing Words 379

    Underlining Words 379

    Resizing Words 379

    Changing the Color of Words 379

    Putting It All Together 380

Chapter 23 Finishing Up and Clicking Publish 381

Editing Techniques 381

    Tackling Different Types of Edits 382

        Editing for Structure 382

        Editing for Details 384

        Editing for Sound 384

        Editing for Coding Errors 384

        Editing for Mechanical and Grammatical Errors 385

    Navigating to the Proofing Copy 385

Testing Your Game 386

    Questioning Beta Testers 386

    Using Testing Notes 387

Clicking Publish 388

    Hosting Your Project on Philome.la 389

    Hosting Your Project on the Internet Fiction Database 389

    Hosting Your Project on Your Own Site 391

    Comparing the Options 392

Reaching Your Audience 392

    Posting on IFDB.tads.org 392

    Posting on Forums 392

Joining the Gaming Community 393

    Participating in Jams 393

    Participating in Competitions 394

    Earning Interactive Fiction Awards 394

Breaking the Rules 394

9780789756640   TOC   4/11/2016


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020