
Learning Ink
- Part 1: Installing Inky and Common Terms
- Part 2: Choices and Knots
- Part 3: Sticky and Advanced Choices
- Part 4: Includes and Stitches
- Part 5: Alternatives, Sequences, Cycles, and Shuffles
- Part 6: Gather Points and Labelled Options
- Part 7: Global, Temporary, and Constant Variables
- Part 8: Knot Parameters and Functions
- Part 9: Tunnels and Threads
- Part 10: Lists
Ink is a scripting language for creating interactive fiction like choose-you-own-adventures and other vast, branching stories.
Global Variables
Like many other scripting languages, Ink also understands scope. When created, the type of scope for a variables is defined in how it is created.
Global variables are defined using the keyword “VAR”. They can be used, updated, and accessed across the entire flow. They can contain numbers, strings, and even diverts.

Similar to other entities like a knot or stitch, the value of a variable can be shown using curly brackets, {}.

When using curly brackets and a defined, global variables, its value can be shown in multiple places.

Temporary Variables
When a global might be too much, or a number of calculations need to be carried out through creating new values per step, temporary variables can be used.
Temporary variables are created through using the tilde and the keyword “temp”. Once created, they last during the life of the knot or stitch in which they were created.

Like other variables, they can also be used as part of conditional statements, checking, like with knots, if their values meet certain criteria.

Constant Variables
Like global variables, constants are set and can be accessed throughout a flow. However, unlike global variables, they cannot be changed once set. Their values are constant.
Constants are created using the keyword “CONST”.

Like other variables, their values can be shown through using curly brackets.

Through combining types of variables and considering their scope, flows can be shaped in dynamic ways.

GitHub Gist Version:
https://gist.github.com/videlais/e959bfed91c566a4b9794efbb7868d49