§17.20. Multiple action processing

When the player types a command like DROP ALL, this is (usually) a request to carry out more than one action. After the command parser has decided what constitutes "ALL" (a process which can be influenced using the "deciding whether all includes" activity), it forms up a list and then runs through it, starting an action for each in turn. The result usually looks something like this:

>GET ALL
foxglove: Taken.
snake's head fritillary: Taken.

However, by adding rules to the rulebook:

multiple action processing rules

we can take a look at the actions intended, and rearrange or indeed change them before they take effect. To do that, we have to deal with a special list of objects. For two technical reasons this isn't stored as a "list of objects that varies" - first because it needs to exist even in low-memory situations where we can't afford full list-processing, and second because there are times when changing it might be hazardous. Instead, two phrases are provided to read the list and to write it back:

multiple object list ... list of objects

This phrase produces the current multiple object list as a value. The list will be the collection of objects found to match a plural noun like ALL in the most recent command typed by the player. If there is no multiple object, say if the command was TAKE PEAR, the list will be empty: it won't be a list of size 1.

alter the multiple object list to (list of objects)

This phrase sets the multiple object list to the given value. The list is ordinarily the collection of objects found to match a plural noun like ALL in the most recent command typed by the player, but using this phrase at the right moment (before the "generate action rule" in the turn sequence rules takes effect).


arrow-up.pngStart of Chapter 17: Understanding
arrow-left.pngBack to §17.19. Does the player mean...
arrow-right.pngOnward to §17.21. Understanding mistakes

In a gallery, there are many individual things to look at, but you can also get a general impression by just examining them as a collection.

First, we'll make a kind for the paintings exhibited in the gallery, and then we'll also make a special object to represent all of them as a mass:

paste.png "Western Art History 305"

A painting is a kind of thing. A painting is usually fixed in place. Understand "painting" as a painting. Understand "paintings" as the plural of painting.

The painting-collective is a thing. The printed name of the painting-collective is "paintings". The description of the painting-collective is "There's [a list of visible paintings]."

We could if we wanted tweak the description to be different in style in different rooms of the gallery, but this will do for now. Next we need to make it possible to type something like EXAMINE PAINTINGS, which normally wouldn't work because the Standard Rules don't tell Inform to recognise multiple objects with the EXAMINE command (unlike, say, DROP or TAKE). This is easy:

Understand "examine [things]" as examining.

Now to make use of the special object. If the player types EXAMINE PAINTINGS, the multiple object list will become a list of the visible paintings. The following rule looks at this list: if it contains more than one painting, it replaces them with the painting-collective instead. Now there's only one examining action, so we get a reply like "There's an abstract painting, a pointilist painting and a French academic painting." instead of a list of descriptions of each in turn.

A multiple action processing rule when the current action is examining (this is the examine kinds rule):
    let L be the multiple object list;
    let F be L;
    let the painting count be 0;
    repeat with item running through L:
        if the item is a painting:
            increment the painting count;
            remove the item from F;
    if the painting count is greater than one:
        add the painting-collective to F;
        alter the multiple object list to F.

And now some art to try this out on:

Gallery is a room. "Various paintings hang on the walls of this gallery, awaiting critical attention. A side chamber to the north contains smaller works."

The abstract painting, the pointilist painting, and the French academic painting are paintings in the Gallery.

North of the Gallery is the Side Chamber. A handsome miniature is a painting in the Side Chamber. The description of the handsome miniature is "The miniature depicts a uniformed soldier of the late 18th century, with braid on his shoulders and a curl in his beard."

The player carries a small notebook. The description of the notebook is "It contains the notes you've taken so far towards a paper for Western Art History 305. So far you're still feeling a bit uninspired."

Test me with "x paintings / x all / n / x paintings / x all".

**ExampleWestern Art History 305
Allowing EXAMINE to see multiple objects with a single command.

In a gallery, there are many individual things to look at, but you can also get a general impression by just examining them as a collection.

First, we'll make a kind for the paintings exhibited in the gallery, and then we'll also make a special object to represent all of them as a mass:

paste.png "Western Art History 305"

A painting is a kind of thing. A painting is usually fixed in place. Understand "painting" as a painting. Understand "paintings" as the plural of painting.

The painting-collective is a thing. The printed name of the painting-collective is "paintings". The description of the painting-collective is "There's [a list of visible paintings]."

We could if we wanted tweak the description to be different in style in different rooms of the gallery, but this will do for now. Next we need to make it possible to type something like EXAMINE PAINTINGS, which normally wouldn't work because the Standard Rules don't tell Inform to recognise multiple objects with the EXAMINE command (unlike, say, DROP or TAKE). This is easy:

Understand "examine [things]" as examining.

Now to make use of the special object. If the player types EXAMINE PAINTINGS, the multiple object list will become a list of the visible paintings. The following rule looks at this list: if it contains more than one painting, it replaces them with the painting-collective instead. Now there's only one examining action, so we get a reply like "There's an abstract painting, a pointilist painting and a French academic painting." instead of a list of descriptions of each in turn.

A multiple action processing rule when the current action is examining (this is the examine kinds rule):
    let L be the multiple object list;
    let F be L;
    let the painting count be 0;
    repeat with item running through L:
        if the item is a painting:
            increment the painting count;
            remove the item from F;
    if the painting count is greater than one:
        add the painting-collective to F;
        alter the multiple object list to F.

And now some art to try this out on:

Gallery is a room. "Various paintings hang on the walls of this gallery, awaiting critical attention. A side chamber to the north contains smaller works."

The abstract painting, the pointilist painting, and the French academic painting are paintings in the Gallery.

North of the Gallery is the Side Chamber. A handsome miniature is a painting in the Side Chamber. The description of the handsome miniature is "The miniature depicts a uniformed soldier of the late 18th century, with braid on his shoulders and a curl in his beard."

The player carries a small notebook. The description of the notebook is "It contains the notes you've taken so far towards a paper for Western Art History 305. So far you're still feeling a bit uninspired."

Test me with "x paintings / x all / n / x paintings / x all".

In a gallery, there are many individual things to look at, but you can also get a general impression by just examining them as a collection.

First, we'll make a kind for the paintings exhibited in the gallery, and then we'll also make a special object to represent all of them as a mass:

paste.png "Western Art History 305"

A painting is a kind of thing. A painting is usually fixed in place. Understand "painting" as a painting. Understand "paintings" as the plural of painting.

The painting-collective is a thing. The printed name of the painting-collective is "paintings". The description of the painting-collective is "There's [a list of visible paintings]."

We could if we wanted tweak the description to be different in style in different rooms of the gallery, but this will do for now. Next we need to make it possible to type something like EXAMINE PAINTINGS, which normally wouldn't work because the Standard Rules don't tell Inform to recognise multiple objects with the EXAMINE command (unlike, say, DROP or TAKE). This is easy:

Understand "examine [things]" as examining.

Now to make use of the special object. If the player types EXAMINE PAINTINGS, the multiple object list will become a list of the visible paintings. The following rule looks at this list: if it contains more than one painting, it replaces them with the painting-collective instead. Now there's only one examining action, so we get a reply like "There's an abstract painting, a pointilist painting and a French academic painting." instead of a list of descriptions of each in turn.

A multiple action processing rule when the current action is examining (this is the examine kinds rule):
    let L be the multiple object list;
    let F be L;
    let the painting count be 0;
    repeat with item running through L:
        if the item is a painting:
            increment the painting count;
            remove the item from F;
    if the painting count is greater than one:
        add the painting-collective to F;
        alter the multiple object list to F.

And now some art to try this out on:

Gallery is a room. "Various paintings hang on the walls of this gallery, awaiting critical attention. A side chamber to the north contains smaller works."

The abstract painting, the pointilist painting, and the French academic painting are paintings in the Gallery.

North of the Gallery is the Side Chamber. A handsome miniature is a painting in the Side Chamber. The description of the handsome miniature is "The miniature depicts a uniformed soldier of the late 18th century, with braid on his shoulders and a curl in his beard."

The player carries a small notebook. The description of the notebook is "It contains the notes you've taken so far towards a paper for Western Art History 305. So far you're still feeling a bit uninspired."

Test me with "x paintings / x all / n / x paintings / x all".

**ExampleThe Best Till Last
Reordering multiple objects for dramatic effect.