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.
Sticky Choices
Introduced in the previous part as “adding back” choices, the Sticky Choice is one that uses the plus symbol “+”. Instead of being removed, it will stick around.
In the previous extended example, this was used to loop the food choices, having all of the choices stick around each loop.
Conditional Choices
Combining diverts and knots, choices can also be conditionally shown. Because knots have unique names, code can check if they have been visited or not. When placed in curly brackets, {}, the choice will show the text or not based on the name of the knot.
In the above example, the choices “Pizza?” and “Sushi?” will be shown first, as the player has not visited their knots. Once the player visits “Pizza” (making it true), the “Salad?” and “Nothing?” choices will be shown and the “Pizza?” choice will not.
Using Sticky Choices, Knots, and Conditional Choices, the choices will appear and disappear based on if a knot has been visited as they loop.
Multiple Conditionals
Conditionals checking if a knot has been visited can also be used together, checking if the player has seen (or not) a set of different knots.
These can create a series of choices that have to be progressed through in order to continue, looping back and checking if other knots have been seen yet or not.
Advanced Choices
Knot labels are not strictly Boolean (true or false) values. They are actually integers (numbers) and a count of how many times the player have seen the knot.
Testing if the value of the knot label is less than 1 is the same as testing if it has not been seen yet. If it has been seen multiple times, the value will be higher.
Testing for multiple values allows for repeating the loop between choices and knots, allowing for the same choice to be chosen and the outcome changing when repeated.
GitHub Git Version:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It was our first date and we hadn't made dinner plans. | |
He turned to me. "What should we eat?" | |
-> Pizza_Choices | |
=== Pizza_Choices === | |
+ {Pizza < 1} [Pizza?] | |
-> Pizza | |
+ {Pizza} {Salad < 1} [Salad?] | |
-> Salad | |
+ {Pizza} {Salad} {Nothing < 2} [Nothing?] | |
-> Nothing | |
+ {Pizza} {Salad} {Nothing} [Sushi?] | |
-> Sushi | |
=== Pizza === | |
He shook his head. "I don't like pizza." | |
-> Pizza_Choices | |
=== Sushi === | |
"Sushi sounds good!" | |
-> DONE | |
=== Salad === | |
"Not a salad." | |
-> Pizza_Choices | |
=== Nothing === | |
{"We have to eat something!"|"Stop being silly!"} | |
-> Pizza_Choices |