(shuffled: Any, Any, […Any]) → array

Identical to (a:), except that it randomly rearranges the elements instead of placing them in the given order.

Example usage:

(set: $a to (a: 1,2,3,4,5,6))
(print: (shuffled: ...$a))


If you're making a particularly random story, you'll often want to create a 'deck' of random descriptions, elements, etc. that are only used once. That is to say, you'll want to put them in an array, then randomise the array's order, preserving that random order for the duration of a game.

The (either:) macro is useful for selecting an element from an array randomly (if you use the spread ... syntax), but isn't very helpful for this particular problem. The (shuffled:) macro is the solution: it takes elements and returns a randomly-ordered array that can be used as you please.


To ensure that it's being used correctly, this macro requires two or more items - providing just one (or none) will cause an error to be presented.

See also:

(a:), (either:), (rotated:)