Learning Ink: Part 8: Knot Parameters and Functions



Learning Ink


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: