O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Interactive Fiction with Twine

Book Description

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

  • Table of Contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. Foreword
    7. About the Author
    8. Dedication
    9. Acknowledgments
    10. We Want to Hear from You!
    11. Reader Services
    12. Introduction: Introduction to Interactive Fiction
      1. Wait a Second...What Is a Choose Your Own Adventure Book?
      2. Are They Games or Stories?
      3. What Type of Games Can I Make with Twine?
      4. Linear Storytelling Versus Interactive Storytelling
      5. How to Use This Book
    13. 1. The Nuts and Bolts: Getting Started with Twine
      1. Installing Twine
      2. Starting Your First Story
      3. Saving in Twine
      4. Navigating Twine Menus
        1. Getting to Know the Stories Screen
        2. Getting to Know the Blue Grid Screen
        3. Getting to Know the Hover Menu
    14. 2. Using Choice to Create Agency
      1. Designing Agency
        1. Providing Clues
        2. Crafting Meaning
        3. World-Building with Optional Details
        4. Using Choice to Affect Pacing
      2. Imagining Different Choices
        1. Giving Preference Choices
        2. Giving Value Choices
        3. Giving Adventure Choices
        4. Giving Ethical Choices
        5. Giving Cause/Effect Choices
        6. Giving Exploratory Choices
        7. Giving Obtainable Choices
        8. Giving Directional Choices
      3. Plotting Your Story’s Choices
      4. Handling Endings
        1. Using the Fan Story Shape
        2. Using the Hourglass Story Shape
        3. Delaying Branching
      5. Creating Another Type of External Link
    15. 3. Creating a Vivid Setting
      1. Understanding the Importance of Setting
        1. Creating Setting from Prompts
        2. Adding Descriptions with (link:)
        3. Repeating Text with (display:)
      2. Setting Tips and Exercises
        1. Writing What You Know
        2. Being the Player’s Eyes
        3. Considering What a Character Would Notice
        4. Combining Motion with Surroundings
        5. Using Your Other Senses
        6. Considering the Mood of a Place
        7. Drawing the Player’s Attention
        8. Using Descriptive Words
        9. Distinguishing Static and Dynamic Settings
      3. Building a Map-Based Game
      4. Creating a Maze
    16. 4. Designing Puzzles
      1. Finding Puzzle Ideas
        1. Finding Puzzles in Everyday Life
        2. Making Your Puzzles Matter
      2. Building Puzzles in Twine
        1. Finding the Starting Point and End Goal
        2. Adding Layers to Your Puzzle
        3. Finishing the Puzzle
      3. Building Other Types of Puzzles
      4. Using Macros and Hooks
      5. Using Named Hooks
    17. 5. Building Objects with Variables
      1. Using Objects in Interactive Fiction
      2. Building Interactive Objects with Variables
        1. Creating a Variable
        2. Changing a Value
        3. Using Strings
        4. Using Boolean Values
        5. Using Variables in Passages
      3. Building Conditional Statements
        1. Adding a Conditional Statement
        2. Adding More Than One Condition
        3. Keeping Track of the Player
      4. Setting Up Types of Quests
        1. Writing Search Quests
        2. Writing Fetch Quests
        3. Writing Drop-off Quests
        4. Writing End Quests
        5. Writing Rescue Quests
        6. Writing Escape Quests
        7. Writing Transformative Quests
        8. Writing Creation Quests
    18. 6. Stasis, Catalyst, and Climax: Understanding Story Arc
      1. Drawing a Story Arc
      2. Understanding Time and Pacing
      3. Making a Game with Story Arc
        1. Opening a Game in Stasis
        2. Continuing to the Catalyst
        3. Building to the Climax
        4. Returning Back to Stasis
      4. Diagramming the Story
      5. Extending Story Arc
      6. Counting Turns with the (history:) Macro
        1. Controlling Time with (history:)
        2. Controlling Links with (history:)
    19. 7. Exploring Interactive Fiction Genres
      1. Managing Reader Expectations
      2. Creating Chance with the (either:) and (random:) Macros
        1. Using the (either:) Macro
        2. Using the (random:) Macro
      3. Delving into Genres
        1. Exploring Horror
        2. Exploring Fantasy
        3. Exploring Science Fiction
        4. Exploring Mystery
        5. Exploring Espionage
        6. Exploring Adventure
        7. Exploring Magical Realism
        8. Exploring Historical
        9. Exploring Western
        10. Exploring Nautical
        11. Exploring Fairytale and Folklore
        12. Exploring Mythology
        13. Exploring Realistic Fiction
        14. Exploring Other Genres
      4. Understanding Motivations
    20. 8. Constructing Believable Characters
      1. Recognizing the Traits of Successful Characters
      2. Using the (click:), (mouseover:), and (prompt:) Macros
        1. Using the (click:) Macro
        2. Using the (mouseover:) Macro
        3. Using the (prompt:) Macro
      3. Distinquishing Types of Characters
      4. Limiting Characters
        1. Creating a Clear Set of Traits
        2. Setting a Goal
        3. Being Vulnerable
      5. Deepening Character Building
        1. Assigning Purpose
        2. Providing Exposition
        3. Exploring Relationships
    21. 9. Maintaining an Inventory
      1. Managing Inventory with Arrays
      2. Using Variables to Work Around Arrays
      3. Using the (array:) Macro
        1. Building a Basic Array
        2. Adding Items to an Array
        3. Dropping Items from an Array
        4. Checking Strings in an Array
        5. Checking the Array Size
        6. Limiting the Array Size
        7. Troubleshooting Arrays
      4. Using the (count:) Macro
      5. Utilizing Literary Techniques
        1. Using Symbolism
        2. Using Allegory
        3. Using Simile
        4. Using Metaphor
        5. Using Analogy
        6. Using Allusion
        7. Using Irony
        8. Using Hyperbole
    22. 10. Achieving Proper Pacing
      1. Understanding Plot
      2. Setting the Pace with Language
        1. Determining Description Amount
        2. Employing Internal Thoughts
        3. Leaving Information Unknown
        4. Setting the Danger Level
        5. Varying Sentence Length
        6. Regulating Passage Length
        7. Limiting Word Count
        8. Using Sentence Fragments
        9. Moving with Vivid Verbs
      3. Utilizing Setter Links
    23. 11. Foreshadowing Important Clues
      1. Using the (append:) Macro
      2. Using the (prepend:) Macro
      3. Foreshadowing Clues
        1. Dropping Direct Clues
        2. Dropping Subtle Clues
        3. Dropping Dream Clues
        4. Dropping Feeling Clues
        5. Dropping Red Herrings
      4. Creating a Hint System
      5. Including Inside Jokes and Easter Eggs
    24. 12. Making a Role-Playing Game
      1. Using the (datamap:) Macro
        1. Adding Values to the Datamap
        2. Removing Values from a Datamap
        3. Using a Datamap for a Stat System
      2. Establishing Class
        1. Becoming a Wizard
        2. Becoming a Knight
        3. Becoming a Thief
        4. Becoming a Healer
        5. Becoming an Elf
        6. Becoming a Dwarf
        7. Coding Class Selection
      3. Establishing Names
      4. Establishing Personal Characteristics
        1. Choosing Gender, Height, and Weight
        2. Troubleshooting User Play Decisions
      5. Establishing Traits
        1. Deciding on Traits
        2. Determining Hit Points
      6. Making the Next Character
      7. Wrapping Up the Opening
      8. Limiting an Array
    25. 13. Combat and Consequences in Role-Playing Games
      1. Exploring the World
        1. Using Personal Characteristics
        2. Making Consequences
        3. Using Traits
        4. Using Items
      2. Battling Monsters
        1. Starting the Fight
        2. Continuing the Fight
      3. Solving Puzzles
      4. Writing a Conclusion
      5. Taking Your Role-Playing Game to the Next Level
      6. Breaking Down Game Writing into Manageable Chunks
    26. 14. Wiggling Words: Changing the Text Appearance
      1. Changing Fonts
        1. Adding a New Font
        2. Designing Fonts
        3. Picking a Font
      2. Changing Text Style
        1. Adding Style
        2. Changing Understanding
        3. Changing Size
      3. Changing Text Color
      4. Changing Text Transitions
    27. 15. Story Style: Changing the Game Appearance in Harlowe
      1. Navigating the Stylesheet
        1. Setting Up Selectors and Declarations
        2. Changing the Background
        3. Changing the Sidebar
        4. Changing the Font
        5. Changing the Links
      2. Getting Rid of Whitespace
    28. 16. Adding Images in a New Format
      1. Changing Over to SugarCube
        1. Learning a New Macro Format
      2. Deciding to Use Images
        1. Knowing Which Image Files You Can Use
        2. Enhancing Understanding with Images
        3. Enhancing Player Mood with Images
        4. Enhancing Game Play with Images
      3. Adding Images to a Game
        1. Sizing Images Before Uploading
        2. Writing Image Code in a Passage
      4. Using Images Creatively
        1. Making Simple Links
        2. Making Setter Links
        3. Making Mouseover Clues
    29. 17. Setting Up the Pre-Story, Central Story, and Post-Story
      1. Learning New Macros
        1. Using the <<set>>, <<unset>>, and <<print>> Macros
        2. Using the <<if>>, <<else>>, and <<elseif>> Macros
        3. Using the <<nobr>> and <<silently>> Macros
      2. Designing the Pre-Story
        1. Telling or Not Telling
        2. Working the Backstory into the Game
        3. Including Game Tutorials
      3. Designing the Post-Story
        1. Defining the Ending
        2. Moving Beyond Happily Ever After
        3. Making Sequels
    30. 18. Developing a Strong Player Character
      1. Using the <<button>>, <<radiobutton>>, and <<checkbox>> Macros
        1. Learning the <<button>> Macro
        2. Learning the <<radiobutton>> Macro
        3. Learning the <<checkbox>> Macro
      2. Using the <<textarea>> and <<textbox>> Macros
        1. Learning the <<textarea>> Macro
        2. Learning the <<textbox>> Macro
      3. Using the <<click>>, <<append>>, <<prepend>>, <<replace>>, and <<remove>> Macros
        1. Learning the <<click>> Macro
        2. Learning the <<append>> and <<prepend>> Macros
        3. Learning the <<replace>> and <<remove>> Macros
      4. Working with Narrative Voice
        1. Setting the Narrator
        2. Being Consistent
        3. Changing the Point of View
        4. Playing for Research
      5. Communicating with Non-Player Characters
        1. Handling Dialogue
        2. Using Twine Tricks for Conversation
        3. Conveying Nonverbal Communication
        4. Employing Juxtaposition and Contrast
      6. Defining Goals and Assigning Purpose
        1. Creating Blank or Defined Player Characters
        2. Considering Gender
        3. Slipping Into Character
    31. 19. Balancing Pacing and Action
      1. Using the either() and random() Functions
        1. Learning the either() Function
        2. Learning the random() Function
      2. Using the turns() and visited() Functions
        1. Learning the turns() Function
        2. Learning the visited() Function
      3. Using the <<back>> and <<return>> Macros
        1. Learning the <<back>> Macro
        2. Learning the <<return>> Macro
      4. Using the <<display>>, <<actions>>, and <<choice>> Macros
        1. Learning the <<display>> and <<actions>> Macros
        2. Learning the <<choice>> Macro
      5. Saving Your Game
        1. Using the Save Feature
        2. Retrieving a Saved Game
      6. Playing with the Pacing
        1. Speeding Up the Story
        2. Slowing Down the Story
        3. Striking a Pacing Balance
      7. Managing Expectations
        1. Highlighting Change
        2. Using the Rule of Three
        3. Distracting the Player with MacGuffins
    32. 20. Keeping Players Engaged
      1. Returning to Arrays
        1. Building a New Array
        2. Adding Items to an Array
        3. Dropping Items from an Array
        4. Checking Strings in an Array
        5. Limiting the Array Size
        6. Troubleshooting Arrays
      2. Checking Your Inventory
        1. Setting Up an Inventory Passage
      3. Understanding Special Passages
        1. Using the StoryMenu Passage
        2. Using the StoryCaption Passage
      4. Knowing Your Audience
        1. Aiming for a Niche
        2. Speaking Broadly
        3. Writing for One Person
        4. Deciding on Length
        5. Piquing Interest with a Teaser
      5. Recognizing the Three Types of Players
        1. Making Games for Win Seekers
        2. Making Games for Story Seekers
        3. Making Games for Realism Seekers
      6. Keeping Players Engaged
        1. Having a Plan
        2. Being Creative
        3. Giving a Purpose
        4. Rewarding Choices
        5. Leaving Them Dreaming
    33. 21. Show, Don’t Tell
      1. Learning About Other Formats
        1. Adding New Formats in Twine
      2. Utilizing the time() Function and <<timed>> and <<goto>> Macros
        1. Counting Seconds
        2. Building a Timer
        3. Delayed Text
      3. Practicing Showing, Not Telling
        1. Problems with Telling
        2. Describing Actions
        3. Drawing Conclusions
        4. Demonstrating Behavior
        5. Transporting the Reader
        6. Trusting the Reader
      4. Telling, Not Showing
    34. 22. Story Style: Changing the Game Appearance in SugarCube
      1. Navigating the Stylesheet
        1. Reviewing Selectors and Declarations
        2. Changing the Background
        3. Changing the Sidebar
        4. Changing the Font
        5. Changing Links
        6. Creating a Class on the Stylesheet
      2. Using HTML in a Passage
        1. Bolding Words
        2. Italicizing Words
        3. Underlining Words
        4. Resizing Words
        5. Changing the Color of Words
        6. Putting It All Together
    35. 23. Finishing Up and Clicking Publish
      1. Editing Techniques
        1. Tackling Different Types of Edits
        2. Navigating to the Proofing Copy
      2. Testing Your Game
        1. Questioning Beta Testers
        2. Using Testing Notes
      3. Clicking Publish
        1. Hosting Your Project on Philome.la
        2. Hosting Your Project on the Internet Fiction Database
        3. Hosting Your Project on Your Own Site
        4. Comparing the Options
      4. Reaching Your Audience
        1. Posting on IFDB.tads.org
        2. Posting on Forums
      5. Joining the Gaming Community
        1. Participating in Jams
        2. Participating in Competitions
        3. Earning Interactive Fiction Awards
      6. Breaking the Rules
    36. Index
    37. Code Snippets