§21.6. Lists of objects

Lists can be made of values of any kind (including other lists), but lists of objects are especially useful. We could always make these "by hand":

let L be {the pot plant, the foxglove};

But it is usually easier and clearer to use descriptions.

list of (description of values) ... value

This phrase produces the list of all values matching the given description. Inform will issue a problem message if the result would be an infinite list, or one which is impractical to test: for instance "list of even numbers" is not feasible.

While that works nicely for many kinds of value ("list of recurring scenes", say), it's particularly useful for objects:

let L be the list of open containers;
add the list of open doors to L;

means that L now contains the open containers (if any) followed by the open doors (if any). Or, for example:

let L be the list of things;
remove the list of backdrops from L;

makes a list of all non-backdrops.

As mentioned above, lists of objects can be said in two additional ways:

"[L with definite articles]"
"[L with indefinite articles]"

And as mentioned below, they can be sorted in property value order:

sort L in P order;
sort L in reverse P order;

where P is any value property. In all other respects, lists of objects are no different to other lists.


arrow-up.pngStart of Chapter 21: Lists
arrow-left.pngBack to §21.5. Building lists
arrow-right.pngOnward to §21.7. Lists of values matching a description

*ExampleWhat Makes You Tick
Building a fishing pole from several component parts that the player might put together in any order.

Suppose we have an item that produces an interesting result the first time the player lifts it -- a rock with dangerous ants revealed underneath. The effect of the surprise is a little weakened, though, if the player sees that response as the result of a TAKE ALL, when it might be printed like this:

>[3] get all
tent peg: Taken.
water flask: Taken.
trading permit: Taken.
innocent-looking rock: You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.
rusty nail: Taken.

[Your score has just gone down by two points.]

The calm response to "rusty nail" looks odd now, and the score change is disconnected from the event that caused it.

To manage this, we might institute a system so that interesting objects are handled last in their list, like so:

paste.png "Formicidae"

Use scoring.

Section 1 - Procedure

The magic rule is listed before the generate action rule in the turn sequence rules.

A thing has a number called dramatic potential.

This is the magic rule:
    let L be the multiple object list;
    if the number of entries in L is greater than 1:
        sort L in dramatic potential order;
        alter the multiple object list to L.

Section 2 - Scenario

The Foothills is a room. "The land has become hilly; though the soil is still mostly coarse yellow sand, clumps of grass are able to grow in the shadier places. Deep wagon ruts running from the southwest towards the mountains in the northeast show where generations of caravans have already passed."

The water flask, the tent peg, and the trading permit are things in Foothills.

The rock is a thing in Foothills. Before printing the name of the rock when the rock is not handled: say "innocent-looking ". The dramatic potential of the rock is 10.

The rusty nail is a thing in Foothills.

The ant colony is a fixed in place thing. "A busy group of ants are crawling to and fro in the unaccustomed sun." Rule for deciding whether all includes the ant colony while taking: it does not.

Instead of taking the rock when the rock is handled:
    say "It might still have a stray ant or two on it."

After taking the rock:
    now the rock is handled;
    move ant colony to the location;
    move the rock to the location;
    say "You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.";
    decrease score by 2.

Test me with "get peg / drop peg / get all / get rock".

Note that while one could also manipulate the object list to add or remove items at this stage, there's a simpler way to control what Inform considers "ALL" to mean in commands: see the activity "Deciding whether all includes" in the activities chapter.

**ExampleFormicidae
Manipulating the order in which items are handled after TAKE ALL.

Suppose we have an item that produces an interesting result the first time the player lifts it -- a rock with dangerous ants revealed underneath. The effect of the surprise is a little weakened, though, if the player sees that response as the result of a TAKE ALL, when it might be printed like this:

>[3] get all
tent peg: Taken.
water flask: Taken.
trading permit: Taken.
innocent-looking rock: You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.
rusty nail: Taken.

[Your score has just gone down by two points.]

The calm response to "rusty nail" looks odd now, and the score change is disconnected from the event that caused it.

To manage this, we might institute a system so that interesting objects are handled last in their list, like so:

paste.png "Formicidae"

Use scoring.

Section 1 - Procedure

The magic rule is listed before the generate action rule in the turn sequence rules.

A thing has a number called dramatic potential.

This is the magic rule:
    let L be the multiple object list;
    if the number of entries in L is greater than 1:
        sort L in dramatic potential order;
        alter the multiple object list to L.

Section 2 - Scenario

The Foothills is a room. "The land has become hilly; though the soil is still mostly coarse yellow sand, clumps of grass are able to grow in the shadier places. Deep wagon ruts running from the southwest towards the mountains in the northeast show where generations of caravans have already passed."

The water flask, the tent peg, and the trading permit are things in Foothills.

The rock is a thing in Foothills. Before printing the name of the rock when the rock is not handled: say "innocent-looking ". The dramatic potential of the rock is 10.

The rusty nail is a thing in Foothills.

The ant colony is a fixed in place thing. "A busy group of ants are crawling to and fro in the unaccustomed sun." Rule for deciding whether all includes the ant colony while taking: it does not.

Instead of taking the rock when the rock is handled:
    say "It might still have a stray ant or two on it."

After taking the rock:
    now the rock is handled;
    move ant colony to the location;
    move the rock to the location;
    say "You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.";
    decrease score by 2.

Test me with "get peg / drop peg / get all / get rock".

Note that while one could also manipulate the object list to add or remove items at this stage, there's a simpler way to control what Inform considers "ALL" to mean in commands: see the activity "Deciding whether all includes" in the activities chapter.

Suppose we have an item that produces an interesting result the first time the player lifts it -- a rock with dangerous ants revealed underneath. The effect of the surprise is a little weakened, though, if the player sees that response as the result of a TAKE ALL, when it might be printed like this:

>[3] get all
tent peg: Taken.
water flask: Taken.
trading permit: Taken.
innocent-looking rock: You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.
rusty nail: Taken.

[Your score has just gone down by two points.]

The calm response to "rusty nail" looks odd now, and the score change is disconnected from the event that caused it.

To manage this, we might institute a system so that interesting objects are handled last in their list, like so:

paste.png "Formicidae"

Use scoring.

Section 1 - Procedure

The magic rule is listed before the generate action rule in the turn sequence rules.

A thing has a number called dramatic potential.

This is the magic rule:
    let L be the multiple object list;
    if the number of entries in L is greater than 1:
        sort L in dramatic potential order;
        alter the multiple object list to L.

Section 2 - Scenario

The Foothills is a room. "The land has become hilly; though the soil is still mostly coarse yellow sand, clumps of grass are able to grow in the shadier places. Deep wagon ruts running from the southwest towards the mountains in the northeast show where generations of caravans have already passed."

The water flask, the tent peg, and the trading permit are things in Foothills.

The rock is a thing in Foothills. Before printing the name of the rock when the rock is not handled: say "innocent-looking ". The dramatic potential of the rock is 10.

The rusty nail is a thing in Foothills.

The ant colony is a fixed in place thing. "A busy group of ants are crawling to and fro in the unaccustomed sun." Rule for deciding whether all includes the ant colony while taking: it does not.

Instead of taking the rock when the rock is handled:
    say "It might still have a stray ant or two on it."

After taking the rock:
    now the rock is handled;
    move ant colony to the location;
    move the rock to the location;
    say "You reach for the rock and turn it over to reveal a thriving colony of flesh-eating ants. Needless to say, you drop the rock and jump back with a decidedly effeminate scream. They can probably hear you all the way back in the base camp.";
    decrease score by 2.

Test me with "get peg / drop peg / get all / get rock".

Note that while one could also manipulate the object list to add or remove items at this stage, there's a simpler way to control what Inform considers "ALL" to mean in commands: see the activity "Deciding whether all includes" in the activities chapter.