countsuccess: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Countsuccess to countsuccess: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 7: Line 7:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
countsuccess(times, sides, target)
countsuccess(times, sides, target)
</source>
</syntaxhighlight>
<source lang="mtmacro" line>
<source lang="mtmacro" line>
success(times, sides, target)
success(times, sides, target)
</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 20: Line 20:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[t: countsuccess(20, 10, 5)]
[t: countsuccess(20, 10, 5)]
</source>
</syntaxhighlight>
Returns a number that is between {{code|0}} and {{code|20}}, which is the number of dice that rolled higher than {{code|5}}.
Returns a number that is between {{code|0}} and {{code|20}}, which is the number of dice that rolled higher than {{code|5}}.


Line 29: Line 29:
[h: DiceSuccess = 3]
[h: DiceSuccess = 3]
[t: countsuccess(DiceTimes, DiceSides, DiceSuccess)]
[t: countsuccess(DiceTimes, DiceSides, DiceSuccess)]
</source>
</syntaxhighlight>
Returns a number than is between {{code|0}} and {{code|12}}, which is the number of dice that rolled higher than {{code|3}}.
Returns a number than is between {{code|0}} and {{code|12}}, which is the number of dice that rolled higher than {{code|3}}.



Revision as of 17:07, 14 March 2023

countsuccess() Function

Generates random numbers to emulate dice rolls; returns the count of dice rolls that are above a certain target number.

Usage

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

  • times - The number of times to roll the dice.
  • sides - The number of sides the dice possess.
  • target - The number that a dice needs to be equal to or higher to be considered a success.

Examples

Roll twenty ten-sided dice, and return the number that are above five.

<source lang="mtmacro" line> [t: countsuccess(20, 10, 5)] </syntaxhighlight> Returns a number that is between 0 and 20, which is the number of dice that rolled higher than 5.

Roll twelve six-sided dice, and return the number that are above three, using variables. <source lang="mtmacro" line> [h: DiceTimes = 12] [h: DiceSides = 6] [h: DiceSuccess = 3] [t: countsuccess(DiceTimes, DiceSides, DiceSuccess)] </syntaxhighlight>

Returns a number than is between 0 and 12, which is the number of dice that rolled higher than 3.

See Also

For another method of rolling dice, see Dice Expressions.