explode: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Explode to explode: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 7: Line 7:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
explode(times, sides)
explode(times, sides)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|times|The number of times to roll the dice.}}
{{param|times|The number of times to roll the dice.}}
Line 16: Line 16:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[t: explode(1, 20)]
[t: explode(1, 20)]
</source>
</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}}.


Line 24: Line 24:
[h: DiceSides = 10]
[h: DiceSides = 10]
[t: explode(DiceTimes, DiceSides)]
[t: explode(DiceTimes, DiceSides)]
</source>
</syntaxhighlight>
Returns a number than is usually between {{code|5}} and {{code|50}}, with the possibility of the maximum value being higher than {{code|50}}.
Returns a number than is usually between {{code|5}} and {{code|50}}, with the possibility of the maximum value being higher than {{code|50}}.



Revision as of 17:09, 14 March 2023

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

<source lang="mtmacro" line> explode(times, sides) </syntaxhighlight> Parameters

  • times - The number of times to roll the dice.
  • sides - The number of sides the dice possess.

Examples

Roll a twenty-sided dice.

<source lang="mtmacro" line> [t: explode(1, 20)] </syntaxhighlight> Returns a number that is usually between 1 and 20, with the possibility of the maximum value being higher than 20.

Roll five ten-sided dice, using variables. <source lang="mtmacro" line> [h: DiceTimes = 5] [h: DiceSides = 10] [t: explode(DiceTimes, DiceSides)] </syntaxhighlight>

Returns a number than is usually between 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.