Book Image

Dynamic Story Scripting with the ink Scripting Language

By : Daniel Cox
Book Image

Dynamic Story Scripting with the ink Scripting Language

By: Daniel Cox

Overview of this book

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.
Table of Contents (18 chapters)
1
Section 1: ink Language Basics
7
Section 2: ink Unity API
12
Section 3: Narrative Scripting with ink

Changing ink variables outside a story

Variables were first introduced in Chapter 4, Variables, Lists, and Functions. In ink, variables are created using the VAR keyword and an initial value. Throughout a story, the value of a variable can be changed. By comparing their values, variables can also influence the flow of a story.

Variables are global in ink. Once created, they can be accessed by any other part of the code within the same story. This functionality is also carried over into a named property as part of the ink-Unity Integration plugin, called variablesState. Every variable defined in an Ink story can be accessed by using its name.

In this topic, we will examine how to use this property to access and change values in a running ink story. We will begin by looking at how to use the variablesState property and comparing values in ink to control its flow outside the story.

Accessing ink variables

The Story API in Unity provides access to ink variables. In this section...