Skip to main content

Lists

Lists hold ordered numbers, such as a saved dice result. Use a Number list variable to retain a list and a Number or Integer variable for each individual item.

Blocks​

rolled dice player / bot

Returns that side's saved dice values from when dice rolled. Order is d4, d6, d8, d10, d12, d20. Missing results return an empty list.

item … of list

Reads the number at a 1-based position. Missing or invalid positions return 0.

sum / maximum / minimum / length of list

Returns the total, largest value, smallest value, or item count. All four return 0 for an empty list. Select minimum in the dropdown, or drag minimum of list directly from the Lists category.

for each … in list … do

Runs once per number in order, assigning the current number to the chosen variable. Also available in Loops.

Lists can contain up to 100 numbers. The for-each loop captures its input list when it starts. Reassigning the source list inside the loop does not change that captured sequence.

Example: count sixes​

Create playerDice as Number list, and die and sixes as Integer variables:

when dice rolled
set playerDice to rolled dice player
set sixes to 0
for each die in list playerDice
if die = 6 do
set sixes to sixes + 1
print text in UI: create text with "Sixes: " and sixes

In draft test inputs, the player dice-values event input is Text, for example 6, 2, 6. The rolled-dice block turns it into a numeric list; this example produces 2. Reset sixes each event so previous rolls are not counted again.

For a fuller comparison of player and bot totals, highest dice, first dice, and sixes, use the downloadable dice-array example.

Example: find the lowest number​

Connect a Number list variable to minimum of list. For [6, 2, 6], the result is 2; for [-6, -2, -8], it is -8. It reads the current list whenever the expression runs, including lists obtained from dice events.

In Code mode:

let scores: number_list = [6, 2, 6];
button("Lowest score", () => {
print(values.listStatistic({ op: "MIN", list: scores }));
});

An empty list returns 0, just like maximum. If an empty list needs different handling, check its length first.