on writing games

talking in code: variables

what do programmers talk about when they talk about variables?

and even more importantly, why are we talking about variables if this list is about *game writing**?

let’s start with the first question.

a metaphor that helped me as a kid when I started programming was to think of a shelf full of jars.

one can store something in a jar, and it stays there until the next time you want to use it.

when we program, these jars are called variables. you can even label them, just like jars.

we use them to store information that we consider will be useful in the future.

why is this important for narrative?

because it’s essential to use variables to change our story.

to react to player choices.

let’s analyze a small example from the game I’m writing now, using cuentitos, the narrative engine we created at Hidden People Club.

Jaime: I am Jaime.
Jaime stretches out his hand to greet you.
  * I take his hand
    set tactile_sensitivity false
    You shake his hand and he smiles.
  * I look at his hand
    set tactile_sensitivity true
    You get caught up looking at his hand.
    He looks at you and puts his hand in his pocket.

[...]

Mom: April! Thank goodness, I was worried. Now I understand why you were late.
She hugs you and kisses your forehead.
  req tactile_sensitivity false
She puts your blanket over you and sits beside you.
  req tactile_sensitivity true

in this example, we’re using the variable tactile_sensitivity.

if the player chooses the option “I take his hand,” we store the value false. If they choose “I look at his hand,” we store the value true.

throughout our game, this variable can be used to modify the story, in small or large ways.

in the example, April’s mother, who knows her very well, hugs her if she doesn’t have tactile sensitivity, or sits beside her without touching if she does have sensitivity.

this is an example of reaction to state which is something we’ll discuss in a future email.

to recap:

a variable is like a jar of information: it stores data that we can use in the future.

it’s essential to understand that variables are the starting point for creating dynamic stories.