Week 8, inky

This is an edi­tion of Robin Sloan’s video game devel­op­ment diary.

Welcome: to returning readers as well as everyone newly subscribed. If you missed it, week 1 sets up the moti­va­tion behind this project. All the pre­vious edi­tions are avail­able over on my blog.

The k in the hea­dine at the top of the page is — oh no. Ohhh no. There are two of them.


Combination tool

Combination tool, Ger­many or France, ca. 16th century

Good news: the sur­prise writing project that con­sumed two of my weeks is drafted and submitted. The project hasn’t been announced yet, but when it is — soon — I’ll be sure to note it here so you can find out what the fuss was about.

I return to Perils of the Over­world this week with a fresh mind and a hot hand.

Wot I got

Exactly the same game I had two weeks ago!


Getting your hands dirty

This week’s edi­tion will be single-minded; I want to use it as an oppor­tu­nity to intro­duce you to Ink, the scripting lan­guage that con­trols POTO’s branching story and, indeed, the entire logic of the game. Even if you are not a programmer, I think you’ll quickly see how you could use Ink to assemble a branching story of your own.

As I have men­tioned before, Ink is the cre­ation of Inkle Stu­dios, and, unlike many sys­tems of its kind that I’ve encountered, it is not at all aca­d­emic or “experimental.” Totally the opposite, in fact; Ink feels like a tool that has been well-used. There are smooth spots — signs of wear. Patina. It’s wonderful.

One of Ink’s essen­tial char­ac­ter­is­tics is that it looks like plain text. This scripting lan­guage is not lit­tered with braces and paren­theses like the rest of POTO’s source code. In fact, you could easily mis­take a simple Ink script for a screen­play. Maybe a screen­play crossed with a shop­ping list.

Here: I’ll show you a supremely simple Ink script, then explain how it works.

It's time to write the newsletter.

I belly up to the computer.

* I ought to show exactly what I have.
  It's embarrassing, but the point is to really document the process.
  I drop the latest screenshots into the email.
* I want to send one really sparkly screenshot.
  Nobody needs to see how the sausage gets made, right?
  I spend an hour combing through my computer.
* First... I need more coffee.
  Yes. Coffee will help. -> MokaPot

-

Finally, I press "send." -> DONE

= MokaPot

I fill the moka pot and set it on the front burner.

While I wait, I peer out the window.

Wind rustles the bougainvillea across the alley. A sparrow flickers past.

Above the warehouse, high up in the sky, a glittering rent has opened, from which an armada of Xrr'vanian warships now emerges. -> DONE

The Ink engine func­tions as a “text pro­vider” in your game. Reading an Ink script, the engine serves up blocks of text, one by one. A very simple Ink game might show this text directly to the player, plain as a web page with blue inks, but, of course, you don’t have to do that. You can dis­play the text as a page from an enchanted storybook, or as dia­logue shown beneath an ani­mated char­acter (as Neo Cab does), or as tow­ering 3D let­ters made of flame. You could even have your game speak the text, never dis­playing any at all! The pre­sen­ta­tion is totally up to you; Ink only takes respon­si­bility for the text itself.

By default, an Ink script runs straight through, going line-by-line, top to bottom. If you want the story to branch, you need to pro­vide options.

You indi­cate those options with asterisks, like a bul­leted list in a text file. The three options I offer in the script above would be dis­played together, like so:

I ought to show exactly what I have.

I want to send one really sparkly screenshot.

First... I need more coffee.

and the game would then wait for the player to make a selection.

This, right here, might be the soul of the branching story game — but not because of the options. Because of the dis­play.

Ron Gilbert, leg­endary cre­ator of The Secret of Monkey Island and many other games, often makes this observation about dia­logue options: it is the only format in which you can tell a joke that has three simul­ta­neous punchlines. (Or four, or two, or six … )

For me, this is counterintuitive, but, as soon as you start writing Ink, undeniable: the expe­ri­ence of playing a game with a branching story is more about the options offered than the option chosen.

This car­ries with it the bur­den­some real­iza­tion that the options must be very well-written — as well-written as the game’s nar­ra­tion and dia­logue.

Writing for Neo Cab, I pro­posed a rule — I’m not sure anyone else fol­lowed it, but I did — that every option pre­sented had to be, in some sense, true. So, if a pas­senger riding in the back of your cab asked “what’s your favorite food?” rather than offer options like

* Pizza, of course.
* A big, rare burger.
* Steamed broccoli. Mmm.

I might offer

* Pizza, I think? Yeah, pizza.
* My favorite is exactly the same as everyone else's.
* Whatever's cheap.

Do you see how, instead of negating each other, those options all kinda work together, and even the ones you don’t choose tell you some­thing about the char­acter? But they’re not interchangeable, either; each pushes the con­ver­sa­tion in a dif­ferent direction. One is straightforward, another is surly, etc.

(This rule obvi­ously doesn’t work everywhere. Some­times you really do have to choose between the poison swamp and the haunted forest.)

Back to my Ink example. Beneath each bul­leted option, there’s addi­tional text:

* I want to send one really sparkly screenshot.
  Nobody needs to see how the sausage gets made, right?
  I spend an hour combing through my computer.

That text is only dis­played if the player chooses that option. It can go on as long as you want, and it can even con­tain nested options. For example, I might build out my second option like this:

* I want to send one really sparkly screenshot.
  Nobody needs to see how the sausage gets made, right?
  * * I find one screenshot that looks extra slick.
      It's a render from a 3D program, but, close enough.
  * * I photoshop a few of the best screenshots together.
      I mean, it's still technically a picture of the game.
      Right?

But we can’t build our entire game out of increasingly-nested options. Besides the fact that the Ink script would be impos­sible to read and/or edit, we often want two or more options to flow into the same outcome.

Ink offers a bunch of tools for leaping around. One of the most basic is the “divert” arrow, ->, which is a simple GOTO. In the example above, where I’ve written -> MokaPot, the Ink engine reads: “Jump imme­di­ately to the module named MokaPot.”

Fur­ther down, you’ll find that module, which Ink calls a “knot.” In practice, Ink scripts tend to be large-ish col­lec­tions of knots, =DungeonEntrance and =PitOfPoison and =CelestialObservatory and so forth. Alternatively, =SadToSeeHimGo and =ConfessTrueFeelings and =RunAfterTrain and so forth. (Wait, why “alternatively”? Maybe those are all in the same game!) Then, options in each knot send the player bouncing between them.

Those are the absolute ground-floor basics of Ink. What really dis­tin­guishes this scripting lan­guage are the affor­dances avail­able one level up.

For example, there’s some­thing called a “gather,” indi­cated with a dash. You can find one in my example above, just above the word “Finally.” A gather tells the Ink engine: “Whatever’s hap­pened before this point — whatever options the player has chosen — just bring it all together here, and keep going.”

It turns out you want to do that a lot in a branching story game. Not every option can, or should, send the story careening off in a new direction! Many options are offered for rea­sons orthog­onal to the story. Maybe you want to do a little worldbuilding; maybe you want to give the player a break from reading; maybe you want to tell a joke with three punchlines! Doing any of those things should not require you to splinter your game into three or more diver­gent realities, each to be resolved with equal richness.

This is the shape of a lot of the Ink that I write: nar­ra­tion, options, gather; nar­ra­tion, options, gather — with par­tic­u­larly momen­tous options diverting to a dif­ferent knot.

Does that make sense? There’s a ton more. I mean, I imple­mented the game of black­jack using Ink; it has variables, if/then statements, log­ical operators, all of that. Ink also has ter­rific documentation, and a quick scroll through this page will reveal how much power is hiding under the hood. But the nice thing is, you can ignore almost all of it.

(Steve Jobs voice:) One more thing.

Not only has Inkle Stu­dios developed, released, and main­tained this rich, useful scripting lan­guage; they’ve also developed, released, and main­tained an editor for it. I draft all my Ink using this editor, called Inky, which is free to download.

So! If any of this seems inter­esting to you, I encourage you to check it out. You can open up Inky, paste in my supremely simple script above, and imme­di­ately “play through it” in the editor’s built-in viewer. Then add some options of your own! It’s all very min­imal, but it turns out min­imal is exactly what you want when you’re pro­to­typing these branches, these stories, these games.


Calipers

Calipers, Europe, ca. 17th century

This week

I am back at it, writing new locations. Hot hand!

From Oakland,

Robin


This has been an edi­tion of my video game devel­op­ment diary, sent by email every few weeks. You can subscribe: