# Listening to the Bird

The very simple game we implemented in Chapter 3 is just about all right — provided all its players do exactly what we expect them to. As soon as any of them depart from our expected script, problems may begin to emerge. For example, consider this opening transcript which could well be generated by someone playing the game:

    In front of a Cottage
    You stand outside a cottage. The forest stretches east.

    >e

    Deep in the forest
    Through the dense foliage, you glimpse a building to the west. A track heads to the northeast.

    You can see a baby bird here.

    >x bird
    Too young to fly, the nestling tweets helplessly.

    >listen to bird
    You hear nothing out of the ordinary.

Since the description of the bird calls attention to the sound it's making, this final response is rather jarring; most players would take it as evidence of a poorly-implemented game. While "You hear nothing out of the ordinary" is okay as a default response to commands like LISTEN TO NEST or LISTEN TO TREE, it just won't pass muster here. It's easy enough to put right, though; all we need to do is to override the listenDesc property of the bird to provide a more satisfactory response:

    + bird: Thing 'baby bird;;nestling'
        "Too young to fly, the nestling tweets helplessly. "

        bulk = 1

        listenDesc = "The nestling sounds scared and in need of assistance. "
    ;

Now all should be well. If you recompile the game and try to listen to the bird you should now see a more appropriate response. Incidentally, you should get precisely the same response if you just enter the command LISTEN in the presence of the bird, since this displays the listenDescs (if not nil) of all the audible items in scope (on the assumption that the player wants a report of all the sounds in the vicinity). That's why we defined listenDesc as "The nestling sounds scared and in need of assistance" rather than "It sounds scared and in need of assistance", since the latter wouldn't make so much sense if the player had just typed LISTEN.

Alternatively, if you didn't want the bird's tweeting to be reported in response to a bare LISTEN command, you could define isProminentNoise = nil on the bird.

You can deal with SMELL, FEEL and TASTE in exactly the same way, by defining smellDesc, feelDesc and/or tasteDesc on the appropriate objects. smellDesc works just like listenDesc, in that a bare SMELL command will report the smellDescs of everything in the vicinity that has one (provided its isProminentSmell property is true). This doesn't happen with feelDesc and tasteDesc however, since the intransitive commands FEEL and TASTE wouldn't make much sense.

adv3Lite Library Tutorial
Table of Contents | Heidi Revisited > Listening to the Bird
Prev: Heidi Revisited Next: Entering the Cottage