Learning Ink: Part 9: Tunnels and Threads



Learning Ink


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



In Ink, it can often be useful to a create knot that is returned to multiple times throughout a flow. Instead of a complex series of diverts and knots, Ink has functionality to quick go to a knot and then return called a tunnel.

As it names implies, tunnels are connections between sections where the flow is diverted to a knot or stitch and then returns again. The player passed through the “tunnel” and out the other side back to the same or different place.

Tunnels are created using the divert (arrow) to “go to” a knot or stitch and then a second divert after the name of the knot or stitch.


To return from the tunnel, use two divert symbols in a row. This will “twice divert” back to the original location.



In some ways, threads are the opposite of tunnels and using diverts. Instead of “going out”, threads “pull together” knots and stitches as part of a flow. To use threading, the arrow changes and points in, “<-“.


Using threads helps separate knots into logical sections of code for the author and developer and then “thread” them all together again.



GitHub Gist Version: