Dynamic Story Scripting with the ink Scripting Language

Book description

Bring your stories to life by combining the narrative scripting language, ink, with a plugin to build dialogue, quest, and procedural storytelling systems for Unity projects

Key Features

  • Learn how to translate stories into ink code to create interactive projects
  • Gain valuable insight into the ink story API to create engaging stories using the Unity plugin
  • Develop drop-in solutions to common narrative problems for Unity projects

Book Description

ink is a narrative scripting language designed for use with game engines such as Unity through a plugin that provides an application programming interface (API) to help you to move between the branches of a story and access the values within it.

Hands-On Dynamic Story Scripting with the ink Scripting Language begins by showing you how ink understands stories and how to write some simple branching projects. You'll then move on to advanced usage with looping structures, discovering how to use variables to set up dynamic events in a story and defining simple rules to create complex narratives for use with larger Unity projects. As you advance, you'll learn how the Unity plugin allows access to a running story through its API and explore the ways in which this can be used to move data in and out of an ink story to adapt to different interactions and forms of user input. You'll also work with three specific use cases of ink with Unity by writing a dialogue system and creating quest structures and other branching narrative patterns. Finally, this will help you to find out how ink can be used to generate procedural storytelling patterns for Unity projects using different forms of data input.

By the end of this book, you will be able to move from a simple story to an intricate Unity project using ink to power complex narrative structures.

What you will learn

  • Discover how ink understands stories and their parts
  • Examine ink patterns for making branching narratives
  • Develop code in Unity using the ink plugin to manipulate stories
  • Design advanced projects combining ink stories with C# code
  • Compare common use cases for ink and Unity, such as dialogue systems
  • Determine how ink can best fit into future narrative projects

Who this book is for

This book is for Unity developers looking for a solution for narrative-driven projects and authors who want to create interactive story projects in Unity. Basic knowledge of Unity game engine development and related concepts is needed to get the most out of this book.

Table of contents

  1. Dynamic Story Scripting with the ink Scripting Language
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Section 1: ink Language Basics
  7. Chapter 1: Text, Flow, Choices, and Weaves
    1. Technical requirements
    2. Understanding branching narratives as a flow
      1. Nonlinear storytelling
      2. Introducing ink
      3. Text flowing down
      4. The smallest unit is a line
      5. Gluing lines together
      6. Using comments as notes to authors
    3. Creating choices and making weaves
      1. Making weaves
      2. Choices within choices
      3. Selective choice output
      4. Gathering points
    4. Disappearing and sticky choices
    5. Summary
    6. Questions
  8. Chapter 2: Knots, Diverts, and Looping Patterns
    1. Technical requirements
    2. Tangling a flow in knots
      1. Creating knots
      2. Diverting between knots
      3. Using DONE and END
    3. Moving between sections
      1. Knots and stitches
      2. Dividing up a story across different files
    4. Looping knots
      1. Looping structures
      2. Revisiting sticky choices
    5. Detecting and changing options
      1. Labeled and conditional options
      2. Building dynamic weaves
    6. Summary
    7. Questions
  9. Chapter 3: Sequences, Cycles, and Shuffling Text
    1. Technical requirements
    2. Using alternatives
      1. Sequences
      2. Cycles
      3. Shuffles
    3. Creating multi-line alternatives
      1. Multi-line cycles
      2. Multi-line sequences
    4. Nesting alternatives
      1. Combining cycles and shuffles
      2. Shuffling shuffles
    5. Summary
    6. Q&A
  10. Chapter 4: Variables, Lists, and Functions
    1. Technical requirements
    2. Storing values using VAR
      1. Showing variables
      2. Updating variables
      3. Storing the current values of alternatives
    3. Working with LIST
      1. Making a LIST
      2. Updating LIST values
    4. Calling functions
      1. Common mathematics functions
      2. Using LIST functions
    5. Making new functions and calling knots
    6. Summary
    7. Questions
  11. Chapter 5: Tunnels and Threads
    1. Technical requirements
    2. Diverting to a divert
      1. Making tunnels
      2. Tunneling to tunnels
    3. Pulling on threads
      1. Making threads
      2. Using multiple threads
      3. Ending threads
    4. Combining tunnels and threads
      1. Reusing tunnels and repeating threads
      2. Threads with tunnels
    5. Summary
    6. Questions
  12. Section 2: ink Unity API
  13. Chapter 6: Adding and Working with the ink-Unity Integration Plugin
    1. Technical requirements
    2. Adding the ink-Unity Integration plugin
      1. Finding and importing the plugin
      2. Verifying the package is installed
    3. Working with ink files
      1. Adding ink source files
      2. Editing source files with Inky
      3. Updating ink source files
    4. Adjusting plugin settings
      1. Finding ink-Unity Integration settings
      2. Updating automatic re-compilation
    5. Summary
    6. Questions
  14. Chapter 7: Unity API – Making Choices and Story Progression
    1. Technical requirements
    2. Loading a compiled ink story
      1. Creating a script component
      2. Adding the ink Story API
      3. Running an ink JSON file
      4. Checking whether a story can continue
    3. Selecting options programmatically
      1. Detecting ink choices
      2. Making choices using the Unity API
      3. Loading all text until the next weave
    4. Creating a dynamic user interface
      1. Creating a new project and game objects
      2. Associating Prefab and ink JSON files
      3. Making a dynamic user interface
    5. Summary
    6. Questions
  15. Chapter 8: Story API – Accessing ink Variables and Functions
    1. Technical requirements
    2. Changing ink variables outside a story
      1. Accessing ink variables
      2. Changing the value of the ink variables
    3. Calling ink functions externally
      1. Verifying and evaluating ink functions
      2. Retrieving the ink function text output
    4. Controlling a story through variables and functions
      1. Preparing a user interface
      2. Scripting user interface objects
      3. Adjusting the presentation values
    5. Summary
    6. Questions
  16. Chapter 9: Story API – Observing and Reacting to Story Events
    1. Technical requirements
    2. Listening for variable changes
    3. Dynamically responding to ink stories
    4. Observing multiple ink values
    5. Summary
    6. Questions
  17. Section 3: Narrative Scripting with ink
  18. Chapter 10: Dialogue Systems with ink
    1. Technical requirements
    2. Writing dialogue in Ink using tags
      1. Tagging ink text
      2. Using speech tags
      3. Reviewing approaches to tagging dialogue
    3. Dialogue loops and story knots
      1. Click to continue
      2. Counting choices for trees
    4. User interface models for conversations
      1. Listing dialogue options
      2. Presenting a radial menu for dialogue
    5. Summary
    6. Questions
  19. Chapter 11: Quest Tracking and Branching Narratives
    1. Technical requirements
    2. Making a quest count
      1. Creating a quest template in ink
      2. Choosing specific knots in Unity
    3. Tracking progress across multiple quests
      1. Building on the ink quest template
      2. Making Quest and Dialogue classes in Unity
      3. Organizing multiple quest files
      4. Toggling quests
    4. Displaying and awarding player progression
      1. Tracking quest values
      2. Showing player progress
    5. Summary
    6. Q&A
  20. Chapter 12: Procedural Storytelling with ink
    1. Technical requirements
    2. Introducing procedural storytelling in ink
      1. Random encounters
      2. Weighted randomness
      3. Conditional content
    3. Loading values into ink
      1. Substitution grammars
      2. Story planning
    4. Coding collections in Unity
      1. Using multiple stories
      2. Conditionally choosing stories
    5. Summary
    6. Questions
  21. Assessments
    1. Chapter 1 – Text, Flow, Choices, and Weaves
    2. Chapter 2 – Knots, Diverts, and Looping Patterns
    3. Chapter 3 – Sequences, Cycles, and Shuffling Text
    4. Chapter 4 – Variables, Lists, and Functions
    5. Chapter 5 – Tunnels and Threads
    6. Chapter 6 – Adding and Working with the ink-Unity Integration Plugin
    7. Chapter 7 – Unity API – Making Choices and Story Progression
    8. Chapter 8 – Story API – Accessing ink Variables and Functions
    9. Chapter 9 – Story API – Observing and Reacting to Story Events
    10. Chapter 10 – Dialogue Systems with ink
    11. Chapter 11 – Quest Tracking and Branching Narratives
    12. Chapter 12 – Procedural Storytelling with ink
    13. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Dynamic Story Scripting with the ink Scripting Language
  • Author(s): Daniel Cox
  • Release date: November 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781801819329