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