Multi-examine

version 3 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter: Designing other multiple actions.

    The extension leaves the door open for other similar actions. To define them you need something which mirrors the top of this extension: an action definition, a "multiple action" declaration, and some action rules.

        Multilistening to is an action applying to one thing. Multilistening to is a multiple action.

    The second sentence here tells the extension to subvert normal multiple action behaviour, and deal with the whole group on one line without printing the "Item 1: ... Item 2: ...." lists that follow a "TAKE ALL" command.

    Next, provide some multiple-action grammar:

        Understand "listen to [things]" as multilistening to.

    From here you can write rules as for a normal actions, but you should bear in mind that these rules will be called once for every object matched in the list. To prevent this, use the phrase "forget further objects" first time around, to ensure later objects are ignored.

    If you want to select a representative and use the same machinery as the multiexaming action, then write the following Check rule:

        Check multilistening (this is the check listening classes rule):
            if we can't find a representative, say "Those are making quite different noises. You'll have to be more specific." instead.

    or we could even divert to another action

        Check multilistening (this is the check listening classes rule):
            if we can't find a representative, try listening to the location instead.

    Further objects will be forgotten after a representative search regardless of outcome.

    If the representative search succeeded, we're then free to use the phrase "if we can print <a property> of the representative object" to print text and variable text strings about this representative. But note, this is all we can do: you can't "try examining ..." the representative found as the representation is a kind object and not a thing. There may not even be an object of just that kind in the model world at all to use as a better representative - for example, when examining all the people in the room, there's no native "person" to use as a representative of this kind because everyone is either a man or a woman. So we're limited to printing the text phrase associated with the kind.

    So the multiexamining rule has the following report line:

        Report multiexamining (this is the print group description rule):
            if we can print a group description for the representative obect, rule succeeds;
            say "You can see [the number of entries in the multiple object list in words] [the plural for representative object]." instead.

    And we could write

        A thing has some text called group sound.

        Percussion is a kind of thing. The group sound of percussion is "Banging and clattering."
        Brass is a kind of thing. The group sound of brass is "Crisp and golden."

        Report multilistening (this is the print group sound rule):
            if we can print a group sound for the representative object, rule succeeds;
            try listening to the location instead.

    And remember, we're going to need:

        Check multilistening when not really doing a multiple action (this is the divert to listen rule):
            try listening to the noun instead.