Sponsored By

Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

Learning Inform 7: Part 1

Learn Inform 7 and make interactive fiction in the first part of an on-going series.

Game Developer, Staff

March 4, 2013

7 Min Read

For many years now, text adventures have often been overlooked as an avenue for making games and telling stories. Part of the reason for this is because they are frequently based in a different approach to interaction than many players are accustomed to using. Instead of pressing buttons or touching a screen, text adventures require active engagement and an on-going conversation between player and game. Progression is linked to reading, understanding, and then writing a response.

Unfortunately, the tools for creating text adventures are sometimes as difficult to use as the games are to understand for some players. However, Inform 7 seeks to solve this problem using a specialized programming language designed specifically for making interactive fiction. Because it is “based on natural language,” its programming is often indistinguishable from a written description of the project itself.

(As of this writing, Inform 7 is available for Mac OS X, Windows, and even Linux for Ubuntu, Fedora, and OpenSUSE users. This tutorial will use the Windows version.)

Starting from the splash screen, the options are to start, re-open the last, or open an existing project. Choosing to start a new project will prompt for the name of the new project and that of its author. Both of these can be changed later, but should be supplied to initially generate the source text.

The default view supplies two panes: Source and Documentation. At any time, these can be switched and changed. If wanted, Source can be the active tab on the right or any other combination suitable to the individual author.

Other than the Source itself, the buttons below the top menu represent the most direct access to the project. From left to right, they are Go (builds and runs current Source), Replay (builds and runs Source using the previous skein), Stop (halts the running game), and Release (bundles the project for others to play).

Note: Within Inform 7, a skein is a collection of the words, phrases, and commands entered in a previously running instance of the current project.

Clicking on the Go button (or pressing F5) will produce an error with the current Source of this project. Without a location, it cannot place the player within a space and create the world of the game accordingly. At least one room needs to be added to the project in order to continue.

"The Adventures of Flippr" by Dan Cox 

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore."

Objects within Inform 7 can have descriptions. Depending on the interaction and the rules governing its behavior, these can be shown to the player via different methods. The default reaction for a rooms is to display its description upon the the player entering that area.

Room descriptions are set using quoted text after the initial assertion of the room. After declaring that something “is a room,” its description follows as a separate sentence. However, it can also be set using the “is” keyword: “The description of the Seaside is ‘The beach stretches off into the distance as the waves gently crash upon its shore.’”

Inform 7 understands nouns like this as values. These include places, people, and anything else that can be in a room or with which the player can interact. These values, in turn, have kinds.

Kinds have a is-a relationship to their values. For example, a Person is a Thing is an Object. When defining new kinds of objects for the game world, they are referenced to things Inform already understands. Each new kind, in turn, is then built upwards from the base default set of things.

"The Adventures of Flippr" by Dan Cox

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore."

A dolphin is a kind of animal.

Under Kinds in the Index tab, Inform will list all of the kinds currently in use in the game world. It includes their taxonomy, default values, and if it has certain properties. Each time the game is built, this will update accordingly.

Inform 7 also has a set of default actions. There are the intentions of the player upon the world and may be thought of as verbs. A player takes an action during the course of play and either succeeds or fails in doing it.

Actions produce a result during play. For example, “examining” an object will often display its description. Setting the description of an object can be used to show the player information about it.

"The Adventures of Flippr" by Dan Cox 

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore." 

A dolphin is a kind of animal. Flippr is a dolphin. 
The description of Flippr is "An incredibly smart dolphin."

A player cannot interact with an object unless they are in the same place. In order for the player to be able to interact with Flippr, they both have to be in a room simultaneously. Placing an object requires stating that it “is in” a specified room.

"Adventures of Flippr" by Dan Cox 

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore." 

A dolphin is a kind of animal. Flippr is a dolphin. Flippr is in the Seaside. 
The description of Flippr is "An incredibly smart dolphin." 

Now, upon “examining” Flippr, the player will see the description. This will also add “examine Flippr” to both the Skein and the Transcript. By comparing the two, future sessions can be tested by repeating certain phrases.

Rooms are also not the only objects which can hold things. Containers are a kind of object which hold other things. They can be used to contain items until the player needs them or finally gains access.

"Adventures of Flippr" by Dan Cox 

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore." 

A dolphin is a kind of animal. Flippr is a dolphin. Flippr is in the Seaside. 
The description of Flippr is "An incredibly smart dolphin." 

The bucket is a container. The fish is in the bucket. The bucket is in the Seaside.

The list of built-in actions for any given Inform 7 game is quite extensive. The Actions section of the Index tab shows the available actions for the player. These include things like “taking”, “dropping”, and “inventory”.

Note: Unless a rule is written to override it, using “inventory” (or one of its synonyms) will display a list of the items the player is currently carrying.

Because certain actions require the consent of the other party, many of the default actions will not succeed. This includes actions like “give it to”, “throw at”, and “showing it to” in reference to other objects. In order to produce the responses wanted, a rule must be written to run instead of the default one.

"The Adventures of Flippr" by Dan Cox 

The Seaside is a room. 
"The beach stretches off into the distance as the waves gently crash upon its shore." 

A dolphin is a kind of animal. Flippr is a dolphin. Flippr is in the Seaside. 
The description of Flippr is "An incredibly smart dolphin." 

The bucket is a container. The fish is in the bucket. The bucket is in the Seaside. 

Instead of giving a fish to Flippr: 
             say "He quickly swallowed the fish and asked for another.";
             remove fish from play.

Like in English sentences, independent clauses are joined using a semicolon in Inform 7. Using a colon starts a list of clauses that we be carried out in order. Using a period closes that same list.

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like