$random
This function returns a random number within a specified range.
Usage:
$random[min;max;allowDecimals (yes/no)(optional, default=no)]
- min: The minimum value of the range (inclusive).
- max: The maximum value of the range. The behavior of this value depends on whether decimals are allowed:
- If
allowDecimals
isno
(or omitted):max
is inclusive. The random number will be betweenmin
andmax
, includingmax
. - If
allowDecimals
isyes
:max
is exclusive. The random number will be betweenmin
andmax
, not includingmax
.
- If
- allowDecimals: An optional parameter specifying whether the random number can be a decimal. Defaults to
no
(integers only). Acceptable values areyes
orno
.
Important Notes:
- Remember that
max
is treated differently depending on whetherallowDecimals
is set toyes
orno
.
Example:
!!exec $random[1;6]
This command will return a random integer between 1 and 6 (inclusive). Possible outputs: 1, 2, 3, 4, 5, or 6.
More Examples:
$random[0;1;yes]
- Returns a random decimal number between 0 (inclusive) and 1 (exclusive), such as0.345
.$random[5;10]
- Returns a random integer between 5 and 10 (inclusive).$random[-10;10;yes]
- Returns a random decimal number between -10 (inclusive) and 10 (exclusive).