Twine is much more than just a glorified e-book. Although it is used to create stories, the experience of twine is a much more interactive one. Behind the simple passages and choices/links between them, Twine is able to keep track of certain things using variables and code. Here, I will explain how these variables work and how I will use them.
Boolean Variable
A ‘Boolean’ is a variable that consists of one of two types, true or false. This is the most simple type of variable. For my Twine game, this can be used to keep track of many types of things; such as:
- Do I have a certain type of key?
- Have I spoken to a certain NPC?

On the left are passages, essentially blocks in which the story will take place. Each of these passages have a ‘body‘, within this body is what the player sees when they play the game; however, this is also where the code is implemented. These lines of code will not be visible to the player during gameplay; hence the rounded and square brackets. Between the square brackets is the code required to create links between passages. The grey arrows are how the player is able to navigate between these passages depending on the choices they make.
Here, is the contents of each of the passages, with ‘Test’ being at the top with ‘!hasKey’ and ‘hasKey’ following and finally ‘Locked Door’ at the bottom (Unlock Door exists as Locked door has a link to it but it’s body is empty). The square brackets are the links between passages, with the text on the left being what the player will see, and the right being which passage the link will take them to. In the rounded brackets is; the code that sets and changes variables; and the conditional statements that check for the status of these variables.
