list

list <value>…

Collect any number of values into an iterable over those arguments, in order.

Use it to build an iterable on the spot — a fixed set of choices, a gathered group of entities, or a literal sequence to drive each. The arguments may be of mixed types.

Arguments

Returns

An iterable over the arguments. Consume it with each, count, first, choose, select, or another iterable consumer.

Examples

after command (say) {
  each [list "north" "east" "south"] { <dir>
    do "say I could go $dir."
  }
}

[list ...] builds a three-element iterable that drives each; the mob names each direction in turn. The block parameter <dir> is declared inside the braces, right after {.

after command (say) {
  do "say [count [list 1 hello $self]] mixed values."
}

The arguments can mix types — here an int, a string, and a creature. [count ...] evaluates to 3, so the mob says "3 mixed values."

after command (say) {
  do "say A random color: [choose [list red green blue]]."
}

choose picks one element at random from the list.

See also