Optimizing room descriptions and object lists in Inform 7

Once you start building games in Inform 7, you may notice that the basic process of describing a room and then putting things in it will default to a somewhat rigid or mechanical output. So a common question I get is, “How do I hide things”? Or, “How do I get rid of that long list of items?” I’ve given various bits of advice for different games and situations, but since this is such a common question, I thought I’d summarize some common situations I’ve seen and methods for dealing with them. In preparing these snippets, I’ve put together a small game in my Playfic account, so if you’d prefer to skip to the final product you can play it there. Otherwise, read on!

By the way, the information I’m presenting is covered in detail in the Inform 7 Recipe Book and Writing with Inform, specifically Chapters 3.1 and 17.23-26 respectively.

So consider this scenario: You’re creating an IF based on your dorm, and you start with your own room. You want to the room to feel like a rich environment, so you put a lot of stuff in it. Here’s one way it might occur to you to write that, alongside what this I7 code produces:

Code Output

Room 1 is a room.

The description of room 1 is “You find yourself in an average dorm room.”

Room 1 contains a desk, a lamp, a chair, a bed, curtains, a plant, a lacrosse stick, running shoes, a dirty shirt, and a Che Guevarra poster.

The chair, bed and desk are enterable containers.

Room 1

You find yourself in an average dorm room.

You can see a desk (empty), a lamp, a chair (empty), a bed (empty), curtains, a plant, a lacrosse stick, running shoes, a dirty shirt and a Che Guevarra poster here.

>

Not very elegant, right? Of course, you’d also further enrich each of those items with some form of detailed description, and surely some of the items would be available to interact with (that is, important for your story) and some would simply be static decoration (that is, not important). So the first thing to ask yourself about each item is, “What is it’s purpose?” If it’s just scenery, I7, as it turns out, understands what scenery is. Scenery will be removed from the location contents list, and we can mention it more gracefully in the room description. Furthermore, it will still be there if the player examines it, and scenery is automatically “fixed in place.”

Code Output

Room 1 is a room.

The description of room 1 is “You find yourself in an average dorm room. Sunlight filters through bright green curtains, and a fake plant, adorned with a dirty shirt, casts a shadow across a Che Guevarra poster.”

Room 1 contains a desk, a lamp, a chair, a bed, curtains, a plant, a lacrosse stick, running shoes, a dirty shirt, and a Che Guevarra poster.

The chair, bed and desk are enterable containers.

The plant, curtains, poster, and dirty shirt are scenery.

The description of the plant is “The ficus tree was supposed to make your room feel more like a home, but its layer of dust just reminds you of a shabby dentist’s office.”

Room 1
You find yourself in an average dorm room. Sunlight filters through bright green curtains, and a fake plant, adorned with a dirty shirt, casts a shadow across a Che Guevarra poster.

You can see a desk (empty), a lamp, a chair (empty), a bed (empty), a lacrosse stick and running shoes here.

>examine plant
The ficus tree was supposed to make your room feel more like a home, but its layer of dust just reminds you of a shabby dentist’s office.

>get plant
That’s hardly portable.

>

Getting better, but there’s still the matter of the “(empty)” tags after each container object. (Note: if those containers had contents, they’d be listed here in the parentheses.) We can deal with these in a couple of ways. The most direct is to introduce a rule that intercepts the “printing room description details” action (see chapter 17.15), though be careful to watch the scope of your rule. “Rule for printing room description details: stop.” will turn off that behavior globally. “Rule for printing room description details of room 1: stop.” will only apply for Room 1. And “Rule for printing room description details of the desk: stop.” will only apply to the desk. (Notice, by the way, how I7 can infer two different uses of “of” to indicate ownership of the activity in question. Pretty clever.)

To gain full control of the list of items, it’s important to understand a few concepts that I7 uses here. What we are seeing in Room 1 as a list of items is the “locale description paragraph“, and unless otherwise specified, the contents of that paragraph is the output of the “listing nondescript items" action. Items appear on that list if they have the property “marked for listing.” In the second example above, for instance, you can see that scenery is normally not marked for listing.

We can explicitly set that marked for listing value, but it requires intervening with that listing action. The following example snippet does this to shoes, using the colon and indentation syntax.

Code Output

Room 1 is a room.

The description of room 1 is “You find yourself in an average dorm room. Sunlight filters through bright green curtains, and a fake plant, adorned with a dirty shirt, casts a shadow across a Che Guevarra poster.”

Room 1 contains a desk, a lamp, a chair, a bed, curtains, a plant, a lacrosse stick, running shoes, a dirty shirt, and a Che Guevarra poster.

The chair, bed and desk are enterable containers.

The plant, curtains, poster, and dirty shirt are scenery.

The description of the plant is “The ficus tree was supposed to make your room feel more like a home, but its layer of dust just reminds you of a shabby dentist’s office.”

Rule for printing room description details of the desk: stop.

Before listing nondescript items while in room 1:
    if the shoes are marked for listing:
        now the shoes are not marked for listing;
    if the stick is marked for listing:
        now the stick is not marked for listing.

Room 1
You find yourself in an average dorm room. Sunlight filters through bright green curtains, and a fake plant, adorned with a dirty shirt, casts a shadow across a Che Guevarra poster.

You can see a desk, a lamp, a chair (empty) and a bed (empty) here.

>x shoes
You see nothing special about running shoes.

>get shoes
Taken.

>

Finally — and this may be the most common scenario — let’s say you just want to get rid of that list all together, either by replacing it with your own text or simply relying on the room description. We can do that by dealing with the “printing the locale description” action, (see Ch. 17.24). Rewrite it with “Rule for printing the locale description of room 1: say "Something else" instead.“. Disable it entirely with “Rule for printing the locale description of room 1: stop.“.

Note that this final example is pretty heavy handed, so consider how you might use it to more gracefully adapt your prose or prompt specific behavior. The locale description is useful in the “dark room” scenario, for example.

There’s a lot more nuance available, but I think this blog post is long enough — hopefully not too long to be helpful. I’ve posted the game I used in these snippets over at Playfic.com. You can play with the final version and browse the working source code. Feel free to copy and paste into your own games.

And if you find another technique or have any corrections or revisions to offer for what I’ve posted here, please let me know.

  1 comment for “Optimizing room descriptions and object lists in Inform 7

Leave a Reply

Your email address will not be published. Required fields are marked *