Inform 7 Home Page / Documentation
§3.6. Windows
Calvin Coolidge once described windows as "rectangles of glass." For us, they have two purposes: first, they offer a view of landscape beyond. In the simplest case the view is of an area which will not be interacted with in play, and therefore does not need to adapt to whatever may have changed there:
The window is scenery in the Turret. "Through the window you see miles and miles of unbroken forest, turning from green to flame in the hard early autumn."
More interesting is to adapt the view a little to provide a changing picture: a forest may not change much, but a street scene will. Port Royal 4 allows us to glimpse random passers-by.
The trickiest kind of window allows the player to see another room which can also be encountered in play, and to interact with what is there. Dinner is Served presents a shop window, allowing people to see inside from the street, and even to reach through.
Vitrine handles the complication of a window misting up to become opaque, and thus temporarily hiding its view.
Second, windows provide openings in walls and can act as conduits. Escape shows how a "door" in the Inform sense can become a window. A Haughty Spirit provides a general kind of window for jumping down out of: ideal for escapers from Colditz-like castles.
See Doors, Staircases, and Bridges for a door which can be partially seen through
ExampleVitrine |
Plaza View is a room. "Your uncle's apartment, on loan to you for viewing the parade and celebrations today. This would be more of a sacrifice on his part if he weren't currently yachting around Corfu."
The smart window is a device in Plaza View. It is fixed in place. "A vast smart window [if transparent]overlooks the park[otherwise]has turned to a sheet of hazy blue[end if]." The smart window can be transparent. The smart window is transparent. The description is "An electrochromic device which changes shade and transparency in response to the application of current.
Note the "can be transparent" line. Devices ordinarily are not allowed to have transparency or opaqueness, but we can make an exception in this case. Without that line, attempts to change the transparency of the window will fail.
Carry out switching off the window: now the window is transparent.
Carry out switching on the window: now the window is opaque.
Instead of searching a transparent window: say "Isn't it lovely out there?"
Instead of searching an opaque window: say "The window is currently darkened."
Test me with "look through window / switch window / look through window / look".
ExampleEscape |
Suppose we want to offer the player a window he can climb through, instead of a boring ordinary door. Our window will be like a door in that it connects two rooms, appears in both places, and impedes movement when it is shut. But we also want to add that we can look through it and see what lies on the other side; and we further want to understand "climb through window" or "jump through window" as attempts to pass through it.
We'll start by defining a couple of rooms and making the window a door between them.
Your Bedroom is a room. The bedroom window is a door. It is west of Your Bedroom and east of the Grassy Slope.
Now we have a "bedroom window" object which can be entered. Now, to catch the case where the player types "LOOK THROUGH WINDOW":
Instead of searching the window:
say "Through the window, you make out [the other side of the window]."
The other side of a door is always defined to be the room that we are not currently in when doing the check. When we are in the bedrooom, the other side will be the grassy slope, and vice versa. "Searching" is the action that occurs when the player attempts to LOOK THROUGH something. (To review what grammar gives rise to what actions, we can always consult the Actions portion of the Index.)
Next we want to cover the case where we climb through the window:
And because "climb window" is understood but "climb THROUGH window" is not, we will have to borrow from the chapter on Understanding to add some new vocabulary to the game (and we'll add Jump too, while we're at it):
Understand "climb through [something]" as climbing. Understand "jump through [something]" as climbing.
Now the final piece: Inform will already keep the player from going through a closed window, but it will say "You can't, since the bedroom window is in the way." This is probably not ideal, so we can replace the instruction thus:
Instead of going through the closed window:
say "The window is shut: you'd break the glass."
Test me with "look through window / climb through window / open window / climb through window / look through window / close window / e / open window / e".
ExampleDinner is Served |
Street in Kolonaki is a room. "There is a single round table out on the street here, and a window more or less at knee level looks down into the Olive Tree Gyro Shop, which is partly basement."
The Street contains a round table. The table is scenery. On the round table is a plate. On the plate are a gyro and a mound of fresh potates. The plate is portable. The potates and the gyro are edible. The description of potates is "They'd be called french fries, at home, but these are steak-cut and fried in olive oil." The description of the gyro is "Dripping garlic-yogurt sauce."
Olive Tree Gyro Shop is inside from Street in Kolonaki. Kostis is a man in the Gyro Shop. In the Shop is a stand. On the stand is a rotating column of cooking lamb flesh. In the shop is a closed, openable container called a drinks refrigerator. The refrigerator contains a can of Mythos beer and a can of Coke Light.
Here's the part that allows reaching through the window.
We replace the usual rule that says the player can never reach into a room with one that more specifically checks whether we are trying to reach through the window. If we aren't, we return the usual refusal. If we are, we return a custom refusal if the window is closed ("You can't reach through the closed window"), but allow access if the window is open.
The can't reach through closed window rule is listed instead of the can't reach inside rooms rule in the reaching inside rules.
This is the can't reach through closed window rule:
let reaching through the window be false;
if the container in question is a room and the container in question is not the location:
if the container in question is the Street and the location is the Olive Tree Gyro Shop:
now reaching through the window is true;
if the container in question is the Gyro Shop and the location is the Street:
now reaching through the window is true;
if reaching through the window is true:
if the window is closed:
say "You can't reach through the closed window.";
deny access;
otherwise:
allow access;
otherwise:
say "You can't reach into [the container in question] from here.";
deny access.
And the rest is window-dressing.
After looking when a room (called the next room) is adjacent:
try examining the next room.
Instead of examining a supporter, say "On [the noun] [is-are a list of things on the noun]." Instead of examining an open container, say "In [the noun] [is-are a list of things in the noun]."
The window is a backdrop. It is in the Street and the Shop. The window can be openable. The window can be open. The window is openable and closed. Instead of searching the window in the Street: try examining the shop. Instead of searching the window in the Shop: try examining the street.
Instead of examining a room:
say "Over in [the noun], you can see [a list of visible things in the noun]."
After deciding the scope of the player:
if the player is in the Street, place the Shop in scope;
if the player is in the Shop, place the Street in scope.
Test me with "examine shop / open refrigerator / open window / examine shop / open refrigerator / get beer / in / examine street / out / get gyro / close window / put gyro in refrigerator / open window / put gyro in refrigerator".
ExamplePort Royal 4 |
Our protagonist is imprisoned in Port Royal, waiting out his years, and sometimes through the window of his cell he is able to see someone.
We are, however, obsessive about historical accuracy, so we provide a table of people who really lived in the city, together with the year in which their existence is attested. We want these people to appear in the description only in the year when they are known to have been present. (After all, mortality was high in Port Royal and new people were constantly arriving, so someone's presence one year is no guarantee of their continued existence the next.)
New New Prison is a room. "You have a not very interesting room. Through the window you see passing [current denizen]."
Instead of waiting:
increment the current year;
say "It is now the year [the current year].";
try looking.
When play begins: now the right hand status line is "[current year]".
Every turn:
if the current year is 1692:
say "It turns out you have remained imprisoned until the great earthquake of 1692! Oops.";
end the story.
Current year is a number that varies. The current year is 1664.
To say current denizen:
repeat through the Table of Occupations and People:
if the date attested entry is the current year:
say "[nickname entry] [family entry], [trade entry]";
blank out the whole row;
rule succeeds;
say "absolutely no one".
It is possible to look up a row corresponding to, say, a specific year value using "listed in", but repeat through is convenient here because we know that we will never wind up trying to print entries when no row can be successfully selected.
Trade |
nickname |
family |
Date attested |
"architect" |
"Robert" |
"Snead" |
1684 |
"baker" |
"William" |
"Wingar" |
1683 |
"barber" |
"William" |
"Alcocke" |
1676 |
"blacksmith" |
"William" |
"Davidson" |
1679 |
"bricklayer" |
"Samuel" |
"Richardson" |
1683 |
"butcher" |
"John" |
"Dennis" |
1676 |
"carpenter" |
"John" |
"Albert" |
1675 |
"cabinet-maker" |
"Robert" |
"Avis" |
1666 |
"joiner" |
"Peter" |
"Bartaboa" |
1666 |
"chandler" |
"William" |
"Bates" |
1674 |
"chyrurgeon" |
"William" |
"Axtell" |
1674 |
"chyrurgeon" |
"Thomas" |
"Trapham" |
1678 |
"combmaker" |
"Paul" |
"Bennett" |
1673 |
"cooper" |
"James" |
"Hall" |
1676 |
"cooper" |
"Henry" |
"Pullein" |
1675 |
"cordwainer" |
"George" |
"Barnard" |
1675 |
"cordwainer" |
"Edward" |
"Skannon" |
1680 |
"cordwainer" |
"John" |
"Wilmott" |
1675 |
"drugster" |
"William" |
"Mathews" |
1682 |
"fisherman" |
"Richard" |
"Collingwood" |
1674 |
"glazier" |
"Thomas" |
"Hudson" |
1684 |
"goldsmith" |
"Richard" |
"Lord" |
1677 |
"gunsmith" |
"Stephen" |
"Massey" |
1664 |
"hatmaker" |
"John" |
"Rosewell" |
1683 |
"ivory turner" |
"William" |
"Clifton" |
1691 |
"labourer" |
"John" |
"Dennis" |
1674 |
"limeburner" |
"John" |
"Hardwick" |
1675 |
"mariner" |
"Alexander" |
"Bailing" |
1680 |
"mariner" |
"Thomas" |
"Bowtell" |
1675 |
"mariner" |
"Peter" |
"Claiton" |
1675 |
"mariner" |
"Joseph" |
"Cupid" |
1672 |
"mariner" |
"Michael" |
"Dunn" |
1675 |
"mason" |
"John" |
"Stone" |
1673 |
"merchant" |
"John" |
"Agard" |
1680 |
"merchant" |
"David Lopez" |
"Narbona" |
1674 |
"merchant" |
"Abraham" |
"Langford" |
1675 |
"merchant" |
"John" |
"Sweeting" |
1675 |
"merchant" |
"Charles" |
"Knight" |
1680 |
"merchant" |
"Cornelius" |
"Vandananker" |
1670 |
"merchant" |
"Moses Jesurum" |
"Cordova" |
1675 |
"pewterer" |
"Simon" |
"Benning" |
1667 |
"pipemaker" |
"John" |
"Pope" |
1680 |
"porter" |
"George" |
"Paul" |
1670 |
"poulterer" |
"Richard" |
"Jeffreys" |
1677 |
"sailmaker" |
"Adam" |
"Brewer" |
1671 |
"schoolmaster" |
"Peter" |
"Bird" |
1677 |
"shipwright" |
"William" |
"Cavell" |
1676 |
"tailor" |
"William" |
"Case" |
1676 |
"tailor" |
"Pewter" |
"Ebden" |
1683 |
"waterman" |
"William" |
"Brocke" |
1674 |
"waterman" |
"Joel" |
"Clements" |
1668 |
"wherryman" |
"John" |
"Grant" |
1669 |
"victualler" |
"Barnaby" |
"Adams" |
1675 |
"vintner" |
"Gabriel" |
"Adkins" |
1668 |
"tavern-keeper" |
"John" |
"Baldwin" |
1670 |
"tavern-keeper" |
"Mary" |
"Dayton" |
1664 |
"tavern-keeper" |
"James" |
"Turpin" |
1679 |
"tavern-keeper" |
"Christopher" |
"Mayham" |
1664 |
Test me with "wait / wait / wait / wait / wait / wait / wait / wait / wait / wait".
ExampleA Haughty Spirit |
Suppose we have a game in which the player can climb through windows which overlook rooms below. We want him to be allowed to climb out windows to reach a room on the same level or at most one level lower than the one he's on; otherwise, he should get a refusal, saying that he would break his neck.
To figure out the height distance between the start room and the destination room, we might have a repeat loop look at all the directions one has to follow along the "best route" path between the two rooms, and record any ups and downs; then subtract the number of "up" steps from the number of "down" steps, and report what remains.
To decide what number is the distance (first place - a room) rises above (second place - a room):
let the total distance be the number of moves from the first place to the second place;
if the total distance is less than 1, decide on 0;
let count of down moves be 0;
let count of up moves be 0;
let next place be the first place;
repeat with counter running from 1 to the total distance:
let the way be the best route from the next place to the second place;
if the way is down, let count of down moves be the count of down moves plus 1;
if the way is up, let the count of up moves be the count of up moves plus 1;
let next place be the room the way from next place;
let the decision be the count of down moves minus the count of up moves;
decide on the decision.
Now we just have to create windows and some action rules for interacting with them...
A window is a kind of thing. A window is always fixed in place. A window can be open or closed. A window is usually closed. A window can be openable or unopenable. A window is usually openable.
Understand "climb through [something]" as entering. Understand "jump through/out [something]" as entering.
Before entering a closed window:
say "[The noun] would have to be opened first." instead.
Instead of entering a window:
if the noun overlooks a room (called the far side):
let fall be the distance the location rises above the far side;
if fall is greater than 1, say "You'd break your neck." instead;
say "You tumble into [the far side].";
move the player to the far side;
otherwise:
say "There's nowhere to go."
Instead of examining a window:
say "[The noun] [if the noun is open]opens over[otherwise]gives a view of[end if] [the list of rooms overlooked by the noun]."
Here we must anticipate a little from the chapter on Relations, and provide ourselves with a way of keeping track of how windows and rooms relate to one another:
Overlooking relates various windows to various rooms. The verb to overlook means the overlooking relation. The initial appearance of a window is usually "[The item described] overlooks [the list of rooms overlooked by the item described]."
The Square Keep is above the Winding Staircase. The Winding Staircase is above the Motte. A crown and a broken sword are in the Motte. The Bailey is west of the Motte.
The long window is in the Keep. The long window overlooks the Bailey and the Motte. The narrow window is in the Winding Staircase. The narrow window overlooks the Bailey.
Test me with "jump through window / open window / jump through window / d / x narrow window / open window / climb through window / e / up / down".
We could then add rules to allow the player to look through windows and see things in the rooms below, but that would require more material from later chapters.