- 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.
Knot (and Stitch) Parameters
While knots and stitches can be thought of as “sections of code,” they can also act similar to functions in other programming languages. Parameters can be passed to knots and stitches and used as variables within their sections, allowing for a more modular approach to creating sections that can respond to the data passed to it.
When used in a loop structure, knots with parameters can serve to highlight the previous choices made.
While knots with parameters can work like functions and allow for reacting to data passed to them, Ink does have functions.
Functions are a special type of knot but use the keyword “function”. This also enables them to use additional functionality not available to regular knots and stitches: returning data using the “return” keyword.
Similar to many other scripting languages, functions in Ink can be called, perform some task, and then return the result of the task.
However, while functions enable the useful feature of being able to react and respond with a return value, they also have some limitations.
As covered in the documentation, functions:
- cannot contain stitches
- cannot use diverts or offer choices
- can call other functions
- can include printed content
- can return a value of any type
- can recurse safely
GitHub Gist Version: