This is the second in a series of quick-start Inform 7 tutorials using examples from Colossal Cave Adventure. More information about this tutorial series can be found here: A Quick-Start Guide to Inform 7.
Making Basic Objects
I said this lesson would be about objects, but we’re actually making “things”. It sounds informal, but it’s a technical term in Inform 7.
One of the first places you find in Adventure is a small brick building. You can enter the building by going east from where the game begins. Upon doing so, you will find:
In its most basic form, the source code to build a thing is:
Some food is a thing.
The “some food” item now exists in game, but it needs to be placed in a room, or the player will be unable to access it. Establish Inside Building as a room (discussed in Lesson #1) and then update the source code to:
Some food is a thing. Some food is in Inside Building.
The food in Adventure has some additional text attached. When you first see the food, the game prints “There is tasty food here.”, and if you examine the food, the game prints “Sure looks yummy!”
We can replicate this by altering the initial appearance (text on ground) and the description (examine text) of the food. Here’s the source code:
Some food is a thing. Some food is in Inside Building. The initial appearance of some food is “There is tasty food here.” The description of some food is “Sure looks yummy!”
If the food were a singular object, such as a steak, you would declare it with “A steak is a thing.” instead. Inform will adjust the pronouns according to what you use.
Some objects in Adventure do not appear in the room text, such as the stream and forest at At End Of Road. In Inform, these objects have a property called scenery. Here’s the source code for the forest, which sets the “scenery” property immediately:
The forest is a scenery thing. The forest is in At End Of Road. The description of the forest is “The trees of the forest are large hardwood oak and maple, with an occasional grove of pine or spruce. There is quite a bit of undergrowth, largely birch and ash saplings plus nondescript bushes of various sorts. This time of year visibility is quite restricted by all the leaves, but travel is quite easy if you detour around the spruce and berry bushes.”
Fixed In Place Objects
It would be a problem if you could pick up the forest and walk away with it. Fortunately, when an object is scenery, Inform automatically sets the “fixed in place” property as well as the “scenery” property. You can see this by compiling your source and then using the SHOWME debug command on the forest.
Even if something is not fixed in place, you can make it fixed in place by setting the property deliberately, as follows:
The example is a fixed in place thing. The example is in At End Of Road.
This will produce an object called “the example” which cannot be picked up in the At End Of Road room.
The small wicker cage in In Cobble Crawl is a container. It is open when you find it, it can be opened and closed, and it can contain objects. Here is the source code to create the cage:
There is a room called In Cobble Crawl.
A small wicker cage is an open openable container. A small wicker cage is in In Cobble Crawl. The initial appearance of a small wicker cage is “There is a small wicker cage discarded nearby.” The description of the cage is “It’s a small wicker cage.”
What if you wanted to generate the little bird in a conveniently pre-caged state? You could declare this in the source:
A bird is a thing. A bird is in the small wicker cage.
A supporter is like a container, but the player can place objects on top of it rather than placing objects inside it. Most supporters are pieces of furniture, such as tables and chairs.
When playing Adventure, you can call the forest in At End Of Road a “forest”, but you can also call it “trees”.
To add a synonym to an object, use the following syntax:
Understand “trees” as the forest.
You can also call the forest “hardwood”, “maple”, “pine”, “spruce”, or a number of other things. Fortunately, you can combine all of the options you want into a single sentence.
Understand “tree/trees/oak/maple/hardwood/pine/spruce” as the forest.
Edibility and Other Properties
The SHOWME for the forest includes the property “inedible”, but there is an edible thing in our game – the food. By adding the edible property to the food, as follows:
Some food is an edible thing.
…we can make it possible for the player to eat the food.
Edible/inedible was reasonably obvious, but there are other properties (such as “openable”) that may be less obvious. For a list of properties attached to things, containers, and supporters, go to Index and then to Kinds, and then scroll down until you find a list that starts with “object (plural objects)”.
You can see a full list of properties here for every kind of object in your game. Searching the Inform 7 manual for the name of a property will give you more information about what it is and how it should be used.
Just Scraping the Surface
This lesson covered how to make basic objects, but the things in the wellhouse all have customized functionality.
- The keys unlock the grate and the chains
- You can eat the food, or feed it to the bear
- The lamp allows you to pass safely through the darkness
- The empty bottle can hold water
I’ll cover this ground in future lessons, but if you want to get started on custom functionality now, read chapter 4 (Kinds) and chapter 7 (Basic Actions) in the Inform 7 manual.
To expand your understanding of things, including scenery, supporters, containers, and properties, see the following parts of the Inform 7 manual:
§3.6. Either/or properties
§3.7. Properties depend on kind
§3.10. Properties holding text
§3.11. Two descriptions of things
§17.8. Understanding names
It seems to me it’s a lot easier to program the entire game from scratch than use this tool.
Colossal Cave Adventure – nice choice tho.
It might be for you! But for most people, under most circumstances, it won’t be.
In context, I assume that you already know how to code. Inform 7 is a natural language tool in large part because it was designed to be friendly for an audience of people who don’t know how to code. For someone with no coding background, the idea that you can type “A cave is a room” and have a compiling game is pretty huge.
But apart from that – Inform 7 is an actively developed game engine that has been in development for 23 years. It’s not uncommon for people to create their own parser systems, but it is extraordinarily uncommon for those systems to be as advanced and easy-to-use as I7, or as well-supported with other technology. For example, most people who submit homebrew parser games to IFComp submit them as Windows executables, which reduces their audience significantly. Producing both a virtual machine executable and a web-playable file from the Inform 7 IDE requires a single line of code (“Release with a web interpreter”) and the website iplayif.com can convert any Z-machine or Glulx virtual machine package into a web-playable file.
Although Inform 7 is the most popular English-language parser engine, it doesn’t exist in a vacuum. The most popular competitor to Inform 6 was the TADS system, and I usually recommend TADS 3 to users who prefer a more traditional system. Other well-known parser engines include ADRIFT, Quest, Alan, and HUGO.