Door with a window

I have searched the examples in the Inform 7 manual and tried to apply the general concept to my piece of IF, but I cannot make it work. Can anyone help me make a door with a window. More specifically a door with an old fashioned keyhole that can be looked through to display the other room.

One way to do this would be to make the keyhole a part of the door and give it a custom response to the “searching” action (when the player enters “look through keyhole” or “look in keyhole”, this results in the “searching” action - see the “Escape” example from chapter 3.12).

[code]The Study is a room. “A massive, ancient desk dominates this room. It is rumoured that Sir Toby’s great-great-great-grandfather, Aethelwold the Diligent, returns every Friday night in ghostly form, sitting at his old desk to finish his opus magnum ‘The History of Somerset from the Romans to the Present’. Alas, he doesn’t seem to show up when people are around.”

The oak door is a door. It is south of the Study. The description of the oak door is “A sturdy oak door with a big keyhole for one of those old-fashioned iron keys.”

The Hallway is south of the oak door. “Portraits of Sir Toby’s ancestors line the walls of the imposing hallway.”

The keyhole is a part of the oak door. The description is “It occurs to you that you could look through the keyhole to see the other side.”

Instead of searching the keyhole:
if the oak door is open:
say “Since the door is open, you just look through the doorway. Nothing interesting is going on in the other room.”;
otherwise:
if the location of the player is the hallway:
say “You carefully peep through the keyhole. A translucent, ghostly figure sits at the desk, scribbling fervently.”;
otherwise:
say “You take a peek through the keyhole. All is quiet in the hallway.”[/code]

You could also try to make a completely generalised version by giving every room something like a keyhole-description property, giving every door a keyhole and then calling up the keyhole-description of the appropriate room via phrases from chapter 3.12 (linked above). But maybe something like my small example above suffices.

If you want the player to be able to examine things in the other room, you need to place it’s contents in scope. See the documentation on scope here:

http://inform7.com/learn/man/doc308.html

My failure of a code. I want to make a generic door that appears in more than one location. So I made it a kind. Since I made it a kind it doesn’t seem to want to let me add a keyhole. That or I’m just inept.

[rant]Section 2 - Scenery

The Dining Room is a room. “The Dining Room is a small quaint room. It has a table, but no objects.” North of The Dining Room is The Kitchen. South of The Dining Room is The Entry Hallway.

East of the Entry Hallway is Front Hallway.

A staircase is an open door. A staircase is not openable. A staircase is above Front Hallway and south of The Upstairs Hallway.

West of The Upstairs Hallway is Bedroom Hallway.

An Old Wooden Door is a kind of door. East of The Upstairs Hallway and west of Veronica’s Bedroom is An Old Wooden Door. North of The Upstairs Hallway and south of Bailey’s Bedroom is An Old Wooden Door. North of Bedroom Hallway and south of the Stephanie’s Bedroom is An Old Wooden Door. East of Jennifer’s Bedroom and west of Bedroom Hallway is An Old Wooden Door. North of Audrey’s Bedroom and south of Bedroom Hallway is An Old Wooden Door. The description of An Old Wooden Door is “An Old Wooden Door with a large old fashioned keyhole.”

A keyhole is a part of An Old Wooden Door.

Instead of examining a keyhole:
Say “Through the keyhole, you make out [the other side of the door]”

Bathroom is a kind of room. Veronica’s Bathroom is a Bathroom.

Veronica’s Door is a door. The description of Veronica’s Door is “A large wooden door like the rest in the house. Only it has no keyhole.”

South of Veronica’s Bedroom and north of Veronica’s Bathroom is Veronica’s Door.[/rant]

The error I get is:
[rant]This is the report produced by Inform 7 (build 6G60) on its most recent run through:

In Section 2 - Scenery:

Problem. The nameless Old Wooden Door created in the sentence ‘A keyhole is a part of An Old Wooden Door’ seems to be a door with no way in or out, so either you didn’t mean it to be a door or you haven’t specified what’s on each side. You could do this by writing something like ‘The blue door is east of the Library and west of the Conservatory’.
See the manual: 3.12 > Doors[/rant]

Here is what my code looked like last time it worked:

[rant]Section 2 - Scenery

The Dining Room is a room. “The Dining Room is a small quaint room. It has a table, but no objects.” North of The Dining Room is The Kitchen. South of The Dining Room is The Entry Hallway.

East of the Entry Hallway is Front Hallway.

A staircase is an open door. A staircase is not openable. A staircase is above Front Hallway and south of The Upstairs Hallway.

West of The Upstairs Hallway is Bedroom Hallway.

An Old Wooden Door is a kind of door. East of The Upstairs Hallway and west of Veronica’s Bedroom is An Old Wooden Door. North of The Upstairs Hallway and south of Bailey’s Bedroom is An Old Wooden Door. North of Bedroom Hallway and south of the Stephanie’s Bedroom is An Old Wooden Door. East of Jennifer’s Bedroom and west of Bedroom Hallway is An Old Wooden Door. North of Audrey’s Bedroom and south of Bedroom Hallway is An Old Wooden Door. The description of An Old Wooden Door is “An Old Wooden Door with a large old fashioned keyhole.”

Bathroom is a kind of room. Veronica’s Bathroom is a Bathroom.

Veronica’s Door is a door. The description of Veronica’s Door is “A large wooden door like the rest in the house. Only it has no keyhole.”

South of Veronica’s Bedroom and north of Veronica’s Bathroom is Veronica’s Door.[/rant]

I will have to study up on this scope thing but I don’t think the way StJohnsLimbo set it up will work for me though as I want to have many keyholes.

Anymore advice would be much appreciated.

Try ‘A keyhole is a part of every old wooden door.’

If I do every old wooden door then I get this:

[rant]This is the report produced by Inform 7 (build 6G60) on its most recent run through:

In Section 2 - Scenery:

Problem. You wrote ‘A keyhole is a part of every Old Wooden Door’ : but ‘every’ can only be used on the other side of the verb, because of limitations in Inform (but also to avoid certain possible ambiguities). In general, ‘every’ should be applied to the subject of an assertion sentence and not the object. Thus ‘Sir Francis prefers every blonde’ is not allowed, but ‘Every blonde is preferred by Sir Francis’ is. (It would be different if, instead of Sir Francis who’s just one man, the name of a kind appeared: ‘A vehicle is in every room’ is fine, for example, because ‘vehicle’ is a kind.)
See the manual: 13.17 > Review of Chapter 13: Relations[/rant]

Oh, you need to make a keyhole a kind as well.

A keyhole is a kind of thing.
A keyhole is a part of every old wooden door.