explode: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "<source" to "<syntaxhighlight") |
Cold Ankles (talk | contribs) m (Limit argument and example) |
||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
<syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
explode(times, sides) | explode(times, sides, limit) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|times|The number of times to roll the dice.}} | {{param|times|The number of times to roll the dice.}} | ||
{{param|sides|The number of sides the dice possess.}} | {{param|sides|The number of sides the dice possess.}} | ||
{{param|limit|Total allowed rerolls of each die. Omit, or set to -1 for infinite rerolls.}} | |||
|examples= | |examples= | ||
Roll a twenty-sided | Roll a twenty-sided die. | ||
<syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
[t: explode(1, 20)] | [t: explode(1, 20)] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Returns a number that is usually between {{code|1}} and {{code|20}}, with the possibility of the maximum value being higher than {{code|20}}. | Returns a number that is usually between {{code|1}} and {{code|20}}, with the possibility of the maximum value being higher than {{code|20}}. | ||
Roll a twenty-sided die. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[t: explode(1, 20, 2)] | |||
</syntaxhighlight> | |||
Returns a number that is usually between {{code|1}} and {{code|20}}, with the possibility of the maximum value being {{code|40}}, as the first roll can be {{code|20}}, triggering an additional roll, but if the second roll is {{code|20}}, it won't be rerolled, as it has reached the two roll limit. | |||
Roll five ten-sided dice, using variables. | Roll five ten-sided dice, using variables. | ||
Line 31: | Line 40: | ||
}} | }} | ||
{{change|1.15.0|Added limit argument}} | |||
[[Category:Dice Function]] | [[Category:Dice Function]] |
Revision as of 01:46, 10 February 2024
explode() Function
Generates random numbers to emulate dice rolls; returns the total of a dice roll where dice that are rolled at maximum value are rolled again with the new roll added to the old. There is no limit to the total that that can be returned by this function, but the odds of each individual number decreases as the total increases past the number of
sides
.Usage
explode(times, sides, limit)
Parameters
times
- The number of times to roll the dice.sides
- The number of sides the dice possess.limit
- Total allowed rerolls of each die. Omit, or set to -1 for infinite rerolls.
Examples
Roll a twenty-sided die.
Returns a number than is usually between
[t: explode(1, 20)]
Returns a number that is usually between 1
and 20
, with the possibility of the maximum value being higher than 20
.
Roll a twenty-sided die.
[t: explode(1, 20, 2)]
Returns a number that is usually between 1
and 20
, with the possibility of the maximum value being 40
, as the first roll can be 20
, triggering an additional roll, but if the second roll is 20
, it won't be rerolled, as it has reached the two roll limit.
Roll five ten-sided dice, using variables.
[h: DiceTimes = 5]
[h: DiceSides = 10]
[t: explode(DiceTimes, DiceSides)]
5
and 50
, with the possibility of the maximum value being higher than 50
.See Also
For another method of rolling dice, see Dice Expressions.
- 1.15.0 - Added limit argument