Closet vs. Closet Door in Inform 7

Hello there! I am trying to write my first IF game in Inform 7 and am running into a problem.

I have a room called “Your Bedroom,” and off of that room is another room called “The Closet.” There is a also a door to the closet, which is closed and unlockable, and the player has to open the door to see what’s inside the actual closet. But the parser is interpreting “closet” as “closet door,” and I don’t know how to make it stop doing that. Here is the code as it currently stands:

The Closet is a room. "Just a half-empty closet. There are some wrapped boxes on the shelves here." The closet door is a closed, openable, not lockable door and scenery. It is north of Your Bedroom and south of the Closet. The description is "A white door with a black knob." Understand "closet door" as closet door. Some 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. Some 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."

How can I write the code so “closet door” is one thing and “the closet” is the actual room?

Thanks for all help; I am a longtime adventure and text gamer and am excited about learning Inform and making my own playable gameworld.

  • Eredien

What kind of commands do you expect to target the closet? None of the standard commands apply to rooms (e.g. saying “x your bedroom” won’t work either). If you have something custom like “go to closet” you can use does the player mean… to make the parser choose the room instead of the object.

(An unrelated side note: you don’t have to write things like ‘Understand “boxes” as boxes’ because an item’s internal name is already automatically added to its grammar by default.)

Maybe I am going about this the wrong way: I just want there to be a closet in the larger room of the bedroom, with a door, so that the player can open the door to look into the closet. Should I make the closet something else other than a room? Thanks for the tip about internal names; I have gone through and edited things a bit.

No, that approach looks fine. I’m not sure what the problem is, though. If I compile the example code it works just fine for me; I can open the closet door, enter and exit the closet etc. In what situation do you want the player to be able to refer to the closet itself instead of the door?

Would making it an enterable openable closed fixed in place container serve your purposes?

There are things inside the closet that I want the player to be able to attempt to interact with. To see these things you have to be inside the closet already, but I don’t want the player to be able to be inside the closet until they’ve opened the door to the closet. When you x or look at the closet the parser always returns the description for the closet door instead of the closet (I think due to the way the parser…parses), and I want to be able to tell the player “if you want to look in the closet you’ll have to open the door” and then have them type “x closet” and have it show the closet desc text instead of the closet door desc text.

I think this might work better, yes, I didn’t think of that because I have never tried a container before (as I said this is my first game). Will try it today.

Like I said, the problem is not that the parser would choose the closet door instead of the closet because they’re similarly named, it’s because the examining action doesn’t apply to rooms at all. If you leave the closet and try “x bedroom” that won’t work either even though there’s no other item with the same name because the parser just doesn’t take rooms into consideration when it looks for a match.

You can either turn the closet into an enterable container as Matt suggests or you could add a scenery object inside the closet that catches “x closet”, but that takes a bit more tinkering.

here’s what you need:

a closed openable door called a cdoor is north of Your Bedroom and south of the Closet. .
understand “closet door” or “door” as the cdoor.
the printed name of the cdoor is “closet door”.
The cdoor is a closed, openable, and scenery.
The description is “A white door with a black knob.”