Redirecting a command to a part of an object

I’m have a few dressers with drawers in my game and I’m trying to make inform understand that “open dresser” should operate as “open drawer.” However when I type “open dresser” in one room I get a message like “You can’t reach into [some other room with a dresser].” What do I need to fix?

A dresser is a kind of supporter.  A drawer is a kind of container.  A drawer is part of every dresser. Drawers are openable.  Drawers are usually closed.  The description of a dresser is usually "It's a rather plain dresser.  The drawer is [if the drawer is open]open[else]closed[end if]." The description of a drawer is usually "The drawer is [if the drawer is open]open.[else]closed.[end if]".
Instead of opening a dresser:
	try opening the dresser's drawer.

The reason that the game is giving you the “reach” message it that it reads the instruction “try opening the dresser’s drawer” to refer to a specific dresser drawer, specifically the first one you created in your source code. It is trying to have the player open that drawer; since it’s in another room, we get the reminder that the player is not Plastic Man.

There is more than one way to handle this. My preference is to provide an alias for the dresser in the preamble, and then refer to it in rule’s body:

Instead of opening a dresser (called the hutch): try opening a random drawer that is part of the hutch.

You’ll also note the use of the “random x that part of the y” construction. You’ll need to use this syntax, at least for the present. It is pretty universally despised, so I expect that there will be a more natural way to refer to this one day, but for now that’s how it’s done.

–Erik

Thanks, Erik that worked. Hey you’ve got the same name as me, that’s awesome.

You’ve also done the same thing with your descriptions. You may find that drawers are described as open when a dresser elsewhere is open. To refer to an object in its description, you need to call it “the item described.” Sometimes you can get away without mentioning the object at all by saying “if closed,” but I don’t understand that well enough to tell you when it works.

Try this:

The description of a dresser is usually "It's a rather plain dresser. The drawer is [if an open drawer is part of the item described]open[else]closed[end if]." The description of a drawer is usually "The drawer is [if open]open.[else]closed.[end if]"

Rule of thumb: if you’ve declared “drawer” as a kind of thing, then writing “the dresser” in your code is a bug. You will only ever use “a dresser”, or sometimes “all dressers” or “a random dresser”. Never “the”.

Same goes for “the thing”, “the room”, etc.

[I assume you meant [u]“dresser”[/u] and not “drawer.”]

The I7 compiler doesn’t produce warnings, does it? Then again, if it’s really always a bug, then it should be a compiler error. Are there any suggestions for this on uservoice?

Yes, mistyped there. :slight_smile:

It’s filed: inform7.uservoice.com/forums/573 … s-an-error