randrange
randrange <min> <max>
Pick a random integer between two bounds, inclusive.
Arguments
<min>— an int, the lowest value that may be returned.<max>— an int, the highest value that may be returned.
Returns
An int chosen uniformly at random from the range [min, max], with
both ends included. When min equals max the result is always that
single value.
Examples
after command (say) {
do "say I rolled a [randrange 1 6]."
}
The mob says a number from 1 to 6, chosen fresh each time the handler
runs.
after command (say) {
do "say [randrange 5 5]"
}
With equal bounds the result is fixed: this always says 5.
The result is an ordinary int, so it combines with the operators and feeds numeric built-ins:
after command (say) {
if [ge [randrange 1 100] 90] {
echo $actor "Something rare just happened."
}
}
This fires the inner block roughly ten percent of the time. For a simpler
percentile test, see random.