$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
allowDecimalsisno(or omitted):maxis inclusive. The random number will be betweenminandmax, includingmax. - If
allowDecimalsisyes:maxis exclusive. The random number will be betweenminandmax, not includingmax.
- If
- allowDecimals: An optional parameter specifying whether the random number can be a decimal. Defaults to
no(integers only). Acceptable values areyesorno.
Important Notes:
- Remember that
maxis treated differently depending on whetherallowDecimalsis set toyesorno.
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).