Learning Ink: Part 2: Choices and Knots

InkLogo

 

Learning Ink

 

Ink is a scripting language for creating interactive fiction like choose-you-own-adventures and other vast, branching stories.


 

Choices

The ability to choose different options is core to how Ink works. By showing the user options, they can pick one and then follow different paths through the flow.

Choices are created with the * symbol. When a line starts with this symbol, it becomes a choice for the player. When multiple * symbols are used, they are all options in that set.

1_Choice

When used in a flow, Inky will present the choices in the middle of the screen.

2_FoodPreview

Multiple uses of the * symbols signal new levels (sets) of choices. A single * symbol is the first and more * symbols signal that those choices lead to more.

3_Choices

When one choices leads to others, those will be shown after the content of the first choice.

4_PizzaChoices

 

Selective Output

5_Output

When brackets are used within a choice, it is only shown in the choice itself. It is not part of the output.

6_SelectiveOutput

This can be combined with other text in the choice to show one part in the choice (what the player clicks) and other in the result of the action.

7_ChoiceText

Any text not in brackets will be shown in the output.

8_ChosePizza

Reducing  (and Adding Back) Choices

By default, a choice will remove itself once chosen. As designed, a choice is a one-time event. It is chosen and the others in the set are ignored. However, choices can be “added back” through using the plus “+” symbol. Instead of being removed, these choices can be used multiple times.

12_PlusSymbol

 

 

Knots

As introduced in the Common Terms, a knot is a selection of content. They are created through using using two or more equal signs (=) and the name of the knot. Optionally, and more commonly, they are also closed with three equal signs (=).

Note: Knots names cannot contain spaces, but can use the underscore.

Moving between knots is done through a divert. In Ink, this is an arrow, “->” that “points at” the knot to move to next.

9_KnotsAndDiverts

Simply creating knots is not enough. Knots must not create dead ends in Ink. At a minimum, a knot must divert to a specially-named label called “DONE” to complete it.

10_KnotsWithDone

Combined with brackets for choices, the output of an option can be placed in knots.

11_KnotOutput

 

Loops with Knots

With both knots and diverts, a loop can be created where an option has a divert that points to a knot containing the original choice.

13_Example

With a single choice within the set “pointing to” a DONE label, the others can be used to loop by diverting to the knot holding the choice.

KnotLoops
Knot Loops with Repeating Choices

 

GitHub Gist Version: