Four Stars 2

Scope for listening different from scope for seeing
Example 364

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 Four Stars 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 report listening rule is not listed in the report 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 report smelling rule is not listed in the report 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".
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".
Waning Moon Resort (on the king-size bed)
A spacious room with a flagstone floor, and a dreamcatcher hung over the king-size bed.

You can see a suitcase (closed), a solar lamp (providing light) and a bedside table (on which are a potted plant and a Bose speaker) here.

On the king-size bed you can see a Lindt chocolate.

>(Testing.)

>[1] listen
You hear the soothing whalesong from the Bose speaker.

>[2] x dreamcatcher
The usual web of threads and crystals, feathers and beads.

>[3] switch lamp off
You switch the solar lamp off.

It is now pleasantly lightless in here.

>[4] look
Noisy Perfumed Darkness
You hear the soothing whalesong from the Bose speaker and the yowling from the tomcat outside on the balcony.

You smell the chocolate-hazelnut smell from the Lindt chocolate and the rosemary from the potted plant.

>[5] sleep
The steady soothing whalesong from the Bose speaker prevents your slumber.

>[6] eat chocolate
(first taking the Lindt chocolate)
You eat the Lindt chocolate. Not bad.

>[7] sleep
The steady soothing whalesong from the Bose speaker prevents your slumber.

>[8] get plant
Taken.

>[9] examine plant
You grope about...

The brush of your fingers stirs loose a fresh cloud of rosemary smell.

>[10] open suitcase
You open the suitcase.

>[11] put plant in suitcase
You unceremoniously dump the potted plant into the suitcase, hoping it sustains no important damage thereby.

>[12] close suitcase
You close the suitcase.

>[13] sleep
The steady soothing whalesong from the Bose speaker prevents your slumber.

>[14] look
Noisy Darkness
You hear the soothing whalesong from the Bose speaker and the yowling from the tomcat outside on the balcony.

The place is blissfully odorless.

>[15] examine bose
From the Bose speaker you hear soothing whalesong.

>[16] switch bose off
You switch off the Bose speaker, silencing the soothing whalesong.

>[17] sleep
The steady yowling from the tomcat outside on the balcony prevents your slumber.

Of course, this new version is less happy for the player, as we haven't included any way to silence the cat.