Skip to main content

Pick

Sometimes the bonus provided by a particular class feature may depend on the number of levels a character has in that class. Pick expressions are a way of representing such a case in a succinct manner.

Syntax

Pick expressions start with the pick keyword followed by a key-value list, then the at keyword and finally an index.

Key-Value List

The key-value list is a comma-separated list with each element being of the form key:value and enclosed within the [ and ] symbols.

The key has to be an integer, while the value can be any valid Dragonscript Value.

When a Pick expression is evaluated, the value associated with the largest key less than or equal to the index will be selected.

Index

The index of a Pick expression has the same possible values as a Math Operand. In other words, it can be an integer, a Property or a Math expression.

Examples

Select a number based on Mystic level

pick [2:1, 5:2, 8:3, 17:4, 20:5] at character.mystic.level

The following table describes the result of this Pick expression based on the Mystic level:

Mystic LevelEvaluated Result
10
2 to 41
5 to 72
8 to 163
17 to 194
20 or above5