| 17.27. Deciding the scope of something |
1. When it happens. "Scope" is a term of art in interactive fiction programming: it means the collection of things which can be interacted with at any given moment, which depends on who you are and where you are. Commands typed by the player will only be allowed to go forward into actions if the things they refer to are "in scope". Inform also needs to determine scope at other times, too: for instance, when deciding whether a rule conditional on being "in the presence of" something is valid. It is a bad idea to say anything during this activity.
2. The default behaviour. Is complicated: see the Inform Designer's Manual, 4th edition, page 227. Briefly, the scope for someone consists of everything in the same place as them, unless it is dark.
3. Examples. (a) We very rarely want to forbid the player to refer to things close at hand, but often want to allow references to distant ones. For instance, a mirage of something which is not present at all:
After deciding the scope of the player while in the Shrine: place the holy grail in scope.
Two different phrases enable us to place unusual items in scope:
place (object) in scope
This phrase should only be used in rules for the "deciding the scope of..." activity. It places the given object in scope, making it accessible to the player's commands, regardless of where it is in the model world. Examples:
place the distant volcano in scope;
place the lacquered box in scope, but not its contents;
Ordinarily if something is placed in scope, then so are its parts and (in the case of a supporter or a transparent or open container) its contents; using the "but not its contents" option we can place just the box itself in scope.
|
place the/-- contents of (object) in scope
This phrase should only be used in rules for the "deciding the scope of..." activity. It places the things inside or on top of the given object in scope, making them accessible to the player's commands, but it does nothing to place the object itself in scope. (It might of course be in scope anyway, and if it is then this phrase won't remove it.) Example:
place the contents of the lacquered box in scope;
place the contents of the Marbled Steps in scope;
Note that the object in question can be a room, as in this second example.
|
(b) Another useful device is to be able to see, but not touch, another room:
The Cloakroom is a room. "This is just a cloakroom, but through a vague, misty mirror-window you can make out the Beyond." After looking in the Cloakroom, say "In the mirror you can see [list of things in the Beyond]."
After deciding the scope of the player while in the Cloakroom: place the Beyond in scope.
The Beyond is a room. Johnny Depp is a man in the Beyond.
(This must, however, also be a mirage, as at time of writing Mr Depp is alive and as well as can be expected following the reviews of "Charlie and the Chocolate Factory".) When a room is placed in scope, this is understood as placing its contents in scope rather than the room-object itself. So "place the Ballroom in scope" allows the player to talk about the dancers, the chamber musicians and so forth, but not to "EXAMINE BALLROOM" as such. (This is sensible because actions like examining apply to things: and a room, unlike a container or a supporter, is not a kind of thing.)
(c) In darkness, the scope of someone is ordinarily restricted to his or her possessions (and body), but we can override that:
After deciding the scope of the player while in darkness: place the location in scope.
4. A note about actions. This activity takes place during the process of understanding the player's command, when the action that will take place is not fully known. So if the player types "TAKE SHOEBOX", this activity would happen when SHOEBOX is being examined for meaning. Inform knows the action it would be taking if the current line of command grammar were to be accepted, but it does not yet know to what objects that command would be applied. That means attaching a proviso like "... while taking a container" to a rule for this activity will cause the rule to have no effect - whereas "... while taking" would be fine.
| Example Four Stars 2 Using "deciding the scope" to change the content of lists such as "the list of audible things which can be touched by the player". | |
As we have seen, a well-written understand rule will often solve the problem of allowing the player to apply specific actions to objects not normally in scope. When we need to adjust scope for some other reason than reading the player's command, though, "deciding the scope of..." may come in handy.
For instance, suppose we wanted to extend Waning Moon 1 to add a tomcat on the balcony that will be heard whenever the player listens from the next room, as in:
>listen
You hear the soothing whalesong from the Bose speaker and the yowling from the tomcat.
To do this, we need to make sure that in the rule that assembles our listening description,
Instead of listening to a room:
if an audible thing can be touched by the player, say "You hear [the list of audible things which can be touched by the player].";
otherwise say "A merciful peace prevails."
now includes the tomcat in the "list of audible things which can be touched by the player".
To this end, we're going to change the way we assess scope, but only during the listening action. Otherwise the tomcat remains in the other room and off-limits. The new source text is marked out below:
"Four Stars"
Section 1 - Procedure
A thing has some text called sound. The sound of a thing is usually "silence".
The block listening rule is not listed in the check listening to rules.
Carry out listening to something:
say "From [the noun] you hear [the sound of the noun]."
Instead of listening to a room:
if an audible thing can be touched by the player, say "You hear [the list of audible things which can be touched by the player].";
otherwise say "A merciful peace prevails."
Definition: a thing is audible if the sound of it is not "silence".
Before printing the name of something audible while listening to a room:
say "[sound] from the "
A thing has some text called scent. The scent of a thing is usually "nothing".
The block smelling rule is not listed in the check smelling rulebook.
Carry out smelling something:
say "From [the noun] you smell [scent of the noun]."
Instead of smelling a room:
if a scented thing can be touched by the player, say "You smell [the list of scented things which can be touched by the player].";
otherwise say "The place is blissfully odorless."
Definition: a thing is scented if the scent of it is not "nothing".
Before printing the name of something scented while smelling a room: say "[scent] from the "
Here is our addition:
After deciding the scope of the player while listening or sleeping or looking:
if in darkness:
repeat with locale running through adjacent rooms:
place locale in scope.
A reaching inside rule while listening or sleeping or looking:
rule succeeds.
Section 2 - Scenario
The Waning Moon Resort is a dark room. "A spacious room with a flagstone floor, and a dreamcatcher hung over the king-size bed." The dreamcatcher is scenery in the Resort. The description is "The usual web of threads and crystals, feathers and beads." Instead of taking the dreamcatcher, say "Ah, ah -- you might be tempted to take it as a souvenir, except that the price list in the minibar clearly states they charge $65 apiece if you walk off with one. Cheaper than stealing the Frette bathrobes, but still probably not a good idea."
And now our threat to the player's peace:
The Balcony is outside from the Resort. In the Balcony is a tomcat. The sound of the tomcat is "yowling". After printing the name of the tomcat when the tomcat is not visible: say " outside on the balcony".
From here we continue with the same scenario as before:
The king-size bed is an enterable supporter in the Resort. The description is "200-thread-count Egyptian cotton sheets, according to the website. You would make fun, only they really are extraordinarily comfortable." The player is on the bed. A Lindt chocolate is on the bed. It is edible. The scent of the chocolate is "chocolate-hazelnut smell".
Instead of exiting: say "You are too weary to move."
The suitcase is an openable closed container in the Resort.
An electric light is a kind of device. Carry out switching on an electric light: now the noun is lit. Carry out switching off an electric light: now the noun is unlit. Understand "light" as an electric light.
The solar lamp is an electric light in Waning Moon Resort. The description is "Specially designed to give light in a spectrum resembling sunlight, to improve the mood and make a person energetic." The lamp is switched on and lit.
An electric noisemaker is a kind of device. An electric noisemaker has some text called usual sound. The usual sound of an electric noisemaker is usually "beepbeepbeep". Carry out switching on an electric noisemaker: now the sound of the noun is the usual sound of the noun. Report switching on an electric noisemaker: say "[The noun] goes [usual sound of the noun]!" instead. Report switching off an electric noisemaker: say "You switch off [the noun], silencing the [usual sound of the noun]." instead.
Carry out switching off an electric noisemaker: now the sound of the noun is "silence".
The bedside table is in the Resort. The table supports a potted plant and a Bose speaker. The scent of the potted plant is "rosemary"
The Bose speaker is an electric noisemaker. The usual sound of the speaker is "soothing whalesong". The sound of the speaker is "soothing whalesong". The speaker is switched on.
Instead of touching a device: say "You feel the surface of [the noun] and discover the switch."
Instead of touching a scented thing: say "The brush of your fingers stirs loose a fresh cloud of [scent of the noun] smell."
Rule for printing the description of a dark room: try listening; try smelling; rule succeeds.
Instead of examining an audible thing while in darkness: try listening to the noun. Instead of examining something while in darkness: try touching the noun.
Before touching something when in darkness:
say "You grope about..."
After inserting the plant into something:
say "You unceremoniously dump [the noun] into [the second noun], hoping it sustains no important damage thereby."
Before printing the name of a dark room: if the player can touch an audible thing, say "Noisy "; if the player can touch a scented thing, say "Perfumed ".
Visibility rule when in darkness:
if examining something, there is sufficient light;
there is insufficient light.
Rule for printing the announcement of darkness: say "It is now pleasantly lightless in here." instead.
Rule for deciding the scope of the player while in darkness: place the location in scope.
To decide whether in daylight:
if in darkness, no;
yes.
Instead of sleeping when in daylight:
say "You've never been able to sleep with the light on."
Instead of sleeping when the player can touch an audible thing (called the irritant):
say "The steady [sound of the irritant] from [the irritant] prevents your slumber."
Instead of sleeping when the player can touch a scented thing (called the irritant):
if the irritant is chocolate, say "The smell of chocolate continues to tantalize you, keeping you from sleep.";
otherwise say "You sniffle. [The irritant] is probably acting on your allergies."
Instead of sleeping:
say "You slip easily into the arms of Morpheus.";
end the story finally saying "At last..."
When play begins:
say "You have at last escaped from the airport and gotten through customs; survived an unnerving taxi ride over icy highways; stared down the impertinent concierge; endured the bellhop's catalog of features in your room; and achieved, finally, a moment of peace. Time for a good night's slumber!"
Test me with "listen / x dreamcatcher / switch lamp off / look / sleep / eat chocolate / sleep / get plant / examine plant / open suitcase / put plant in suitcase / close suitcase / sleep / look / examine bose / switch bose off / sleep".
Of course, this new version is less happy for the player, as we haven't included any way to silence the cat.
|
| Example Peeled Two different approaches to adjusting what the player can interact with, compared. | |
|  Example Ginger Beer A portable magic telescope which allows the player to view items in another room of his choice. | |
|  Example Rock Garden A simple open landscape where the player can see between rooms and will automatically move to touch things in distant rooms. | |