How to Write Interactive Fiction and Interactive Audio Stories – 021 – Variables

In TWIST you can save your player’s decisions and have respective events happen later on. To do this, you use variables that can serve all kinds of different purposes. For example:

  • Relationships to other characters like “love”, “sympathy”, “reputation”
  • Attributes like “strength”, “intelligence”, “courage”
  • Abilities like “sneaking”, “fire spell”, “climbing”
  • Items like “key”, “gun”, “flashlight”
  • Player actions like “lever pulled” (opening a door somewhere else), “evidence photo seen” (for the later conviction of the culprit)
  • Resources like “oxygen” (in a damaged space ship), “water supply” (in the desert), “lead” (in a chase), “gold” or “life points”
  • Random numbers for random events or actions with different chances of success

Character Relationships

In a dialogue, for example, between the main character and the king there are several consecutive Player Choices which all influence the value of the variable “king respect”, recording to what extent the player character gains the king’s respect. Through their choices, the player can choose how to behave towards the king.

For example, they can act “loyally” (“king respect” increases by 1) or “defiantly” (“king respect” decreases by 1), be “truthfully” (“king respect” increases by 1) or “dishonestly” (“king respect” decreases by 1), “offer help” (“king respect” increases by 1) or “forsake the kingdom” (“king respect” decreases by 1).

At the end of this dialogue, the variable “king respect” would then have a total value in the range from minus 3 to plus 3 (the specific possible values are -3, -1, +1, or +3).

Relationship variable using the king example (A)

TWIST image: Relationship variable using the king example (A)


After that you can check the variable to have different story paths or events play out. For our example of the dialogue with the king, you could now present the player with one of three new events:

Relationship variable using the king example (B)

TWIST image: Relationship variable using the king example (B)


  1. If the value of “king respect” is less than minus 1, the king has the player character thrown into the dungeons.
  2. If the value is in the range of minus 1 to plus 1, the king remains neutral.
  3. If the value is higher than plus 1, the king will provide the player with an additional piece of equipment and some wise counsel for their quest.

Be aware, though, that the player is not making any decision in that moment. This evaluation happens in the background of TWIST without the player’s knowledge, and it is based on the previously made decisions and the accompanying changes of the value of the variable.

The value “king respect” can also be used at later points for other characters. For example, before a conversation with a grumpy guard the player’s reputation with the king is being checked. The higher the player’s standing with the king, the more eager the guard will be to help them, leading to different events.

TWIST also offers the possibility to use variables across episodes. Especially for relationships to other characters this makes sense. If the player behaves in a hostile manner to a certain character in one episode, that character should not suddenly react friendly to them in another episode as if nothing had happened.

Share The Post