Defining Names

Hi there. I’m writing my first game in Inform 7 on Mac OSX and I am having a lot of trouble trying to figure out how to get around the problem where you need to tell Inform to call or print something in a specific manner.

A few examples:

  • I have a room (the closet) with a scenery door (the closet door).

I want the player to be able to x the following objects:
The closet door itself
The closet (but only if the closet door is open).
Otherwise, when the player types “look closet,” I want it to say something like “you’ll have to open the door first.”

  • I have a scenery table (the computer desk) which I am going to put a computer on.

I want the player to be able to x the following objects:
The computer table itself
The computer
When the player types “look computer,” I want to make Inform figure out that the player is looking at the computer itself, unless they specifically type “computer desk.”

Obviously, this is happening because the parser is only picking up the first word, like “closet” or “computer.” I figured this was a common problem (I’ve played a lot of text adventures with closet doors!) so I poked through the documentation for a workaround.

I have tried a bunch of stuff, including “calling” the “closet door” the “closet door.” But it’s not working, and I know it’s because I’ve messed up the way I’m calling it (looking at it from the complier’s point of view, it’s obviously going to throw an error).

Here’s my current code:

The closet door is a scenery door. The closet door is called the closet door. The closet door is north of Your Bedroom and south of the Closet. It is a closed, openable, not lockable door. The description is “A white door with a black knob.”

The Closet is a room. “Just a half-empty closet. There are some wrapped boxes on the shelves here.”
The boxes are scenery in the Closet. “Colorfully wrapped gifts.” Instead of taking boxes: say “Those aren’t for you, and if you opened them you’d just have to rewrap them and put them back anyway.” Understand “box” or “boxes” or “wrapped boxes” or “wrapped box” or “package” or “packages” or “wrapped package” or “wrapped packages” or “present” or “presents” or “wrapped present” or “wrapped presents” or “gift” or “gifts” or “wrapped gift” or “wrapped gifts” as boxes. Understand “closet” or “closet interior” or “interior of closet” or “closet inside” or “inside of closet” as Closet.
The shelves are scenery in the Closet. “Slightly dusty shelves.” Understand “shelf” or “shelves” as shelves. Instead of taking shelves: say “They’re attached to the wall.”

If somebody could help me out, that would be great–this problem is driving me crazy!

I also looked at the Inform Recipe Book example of Desolation Bay, where there is a room (the Cabin) and a door (the cabin door) with the same problem that I am having, but the problem wasn’t addressed in the Recipe Book, and in the Inform manual the cigarette case example is really not being helpful, here.


You can set things “privately-named” so that their internal names won’t be automatically taken into account when parsing object names. For example to make “computer” match the computer only and not the table:

The computer is on the computer table. The computer table is privately-named. Understand "computer table" and "table" as the computer table.
The same thing with the closet door. Another option is to give the object a different internal name and set the printed name explicitly:

The computer-table is a supporter. The printed name of the computer-table is "computer table". Understand "computer table" and "table" as the computer-table.

The advantage of the first method Juhana mentioned is that it will be easier for you to remember how to refer to the table elsewhere in your code. One of the hidden gotchas in Inform is that if you initially create something called the computer-table and later, because you’ve forgotten how you formatted the object name, refer to something called the computer table, Inform may – depending on what exactly you’ve written – quietly create a second object (which will quite likely be off-stage).


The office is a room. The computer-table is in the office. Understand "computer table" and "table" as the computer-table. The printed name of the computer-table is "computer table". The pencil sharpener is on the computer table.

This will compile, but the pencil sharpener will not be in scope in the office; it will be off-stage, along with the extra object called computer table.

Note, also, that the hyphenated name trick won’t work as expected if the first word is 9 or more letters. By default, Inform only looks at the first 9 letters in each word. And a hyphenated word only counts as one word. So if the first word is too long, the player will be able to use it to refer to the table (unless you also make the table privately-named).

And also because the parser looks at only the first 7 or 8 letters or so, “computer” will probably match “computer-table” as well anyway. So yeah, the privately-named method is probably the more robust solution.