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.
Tunnels
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.
Threads
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:
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
CONST name = "Dan" | |
VAR fretCount = 0 | |
VAR freakOutCount = 0 | |
It was a {weather()} {dayOfWeek()}. | |
I was unsure about asking him out on a date. We had known each other for over six months, but I couldn't work up the nerve. I knew he was single, we got along great, but… what if he turned me down? Or was straight? Dating in the workplace had never worked out for me. But he was cute! And we got along! But I just wasn't sure. | |
(I'm such a nervous wreck!) | |
CHAPTER 1: ASKING HIM OUT | |
-> Chapter_1 | |
=== Chapter_1 === | |
{&(What should I do?) | (What if I didn't say anything?) | (Should I ask him out?) | (Maybe I should move to another city?)} | |
+ [(Did he even like guys?)] | |
~ fretCount++ | |
-> Chapter_1 | |
* [I should just do it!] | |
I let it go for weeks and weeks. I kept seeing him in the office. We'd smile — well, I'd smile and sometimes he'd smile back. (I lived for those smiles.) | |
{fretCount > 2: After thinking about it multiple times, I finally asked him out.} | |
{fretCount < 2: Finally, I asked him out, and he accepted with a smile! } | |
– CHAPTER 2: GETTING READY | |
Why hadn't I thought about what I was going to wear? | |
Here I am, 30 minutes before the date and I haven't picked out my clothes! | |
* (Look_Good) [Pick out something good.] I took some time and picked out something good. | |
* (Random_Clothes) [Don't bother.] I just grabbed some clothes off the floor and ran out. | |
– Finally, I was ready. | |
CHAPTER 3: EATING DINNER | |
He greeted me at the door of his apartment. {Look_Good: "You look good, {name}!"}{Random_Clothes: "Ready?"} | |
But I hadn't made dinner plans! And they we were, standing outside his apartment. | |
He turned to me. "What should we eat?" | |
-> Pizza_Choices("") | |
=== Pizza_Choices(previousChoice) === | |
{previousChoice != "": (We just talked about about having {previousChoice}.) } | |
* [Pizza?] He shook his head. "I don't like pizza." | |
-> Freak_Out -> | |
-> Pizza_Choices("pizza") | |
* [Salad?] "Not a salad." | |
-> Freak_Out -> | |
-> Pizza_Choices("salad") | |
+ [Nothing?] {"We have to eat something!"|"Stop being silly, {name}!"} | |
-> Pizza_Choices("nothing") | |
* [Sushi?] "Sushi sounds good!" | |
We walked to the local sushi place. | |
<- Food_Choices | |
-> END | |
=== Food_Choices === | |
The place was only moderately crowded and we made our way over to a table. After getting our menus, I pondered my choices: sashimi, makizushi, ramen, tempura, and, of course, sushi. | |
-> DONE | |
=== Freak_Out === | |
(Did I freak out over getting the food choice wrong?) | |
+ [No] | |
(I didn't freak out.) | |
->-> | |
+ [Yes] | |
~ freakOutCount++ | |
{ | |
– freakOutCount > 1: | |
I was so stressed out that we ended the date early! | |
-> END | |
– else: | |
(I freaked out a little bit, but I kept it under control.) | |
->-> | |
} | |
=== function dayOfWeek() === | |
~ return "{~Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday}" | |
=== function weather() === | |
~ return "{~sunny|rainy|clear|cloudy}" | |