The Art of Noise
Example 95
★★★This example involves redesigning the LISTEN command, removing its built-in function and replacing that with something more ambitious. We will learn more about how to do this later on.
"The Art of Noise"
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 "Nothing of note."
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 "
The Sharper Image is a room. The pet rock is a thing in the Sharper Image. The toy car is a thing in the Sharper Image. The sound of the car is "whirring and zooming". The plastic widget is a thing in the Sharper Image. The sound of the plastic widget is "bleeps and bloops". The pointless gadget is a thing in Sharper Image. The sound of the pointless gadget is "buzzbuzzbuzz".
The soundproof case is a transparent openable container in the Sharper Image. It is closed and fixed in place.
Test me with "listen / listen to rock / listen to car / get all / open case / put all in case / listen / close case / listen / listen to car".
Test me with "listen / listen to rock / listen to car / get all / open case / put all in case / listen / close case / listen / listen to car".
Sharper Image
You can see a pet rock, a toy car, a plastic widget, a pointless gadget and a soundproof case (closed and empty) here.
>(Testing.)
>[1] listen
You hear the whirring and zooming from the toy car, the bleeps and bloops from the plastic widget and the buzzbuzzbuzz from the pointless gadget.
>[2] listen to rock
From the pet rock you hear silence.
>[3] listen to car
From the toy car you hear whirring and zooming.
>[4] get all
pet rock: Taken.
toy car: Taken.
plastic widget: Taken.
pointless gadget: Taken.
>[5] open case
You open the soundproof case.
>[6] put all in case
pointless gadget: Done.
plastic widget: Done.
toy car: Done.
pet rock: Done.
>[7] listen
You hear the whirring and zooming from the toy car, the bleeps and bloops from the plastic widget and the buzzbuzzbuzz from the pointless gadget.
>[8] close case
You close the soundproof case.
>[9] listen
Nothing of note.
>[10] listen to car
The soundproof case isn't open.
You can see a pet rock, a toy car, a plastic widget, a pointless gadget and a soundproof case (closed and empty) here.
>(Testing.)
>[1] listen
You hear the whirring and zooming from the toy car, the bleeps and bloops from the plastic widget and the buzzbuzzbuzz from the pointless gadget.
>[2] listen to rock
From the pet rock you hear silence.
>[3] listen to car
From the toy car you hear whirring and zooming.
>[4] get all
pet rock: Taken.
toy car: Taken.
plastic widget: Taken.
pointless gadget: Taken.
>[5] open case
You open the soundproof case.
>[6] put all in case
pointless gadget: Done.
plastic widget: Done.
toy car: Done.
pet rock: Done.
>[7] listen
You hear the whirring and zooming from the toy car, the bleeps and bloops from the plastic widget and the buzzbuzzbuzz from the pointless gadget.
>[8] close case
You close the soundproof case.
>[9] listen
Nothing of note.
>[10] listen to car
The soundproof case isn't open.