rollSubWithUpper: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page rollSubWithUpper to RollSubWithUpper without leaving a redirect: Converting page title to first-letter uppercase) |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
rollSubWithUpper(times, sides, sub, maximum) | rollSubWithUpper(times, sides, sub, maximum) | ||
</ | </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: | ||
|examples= | |examples= | ||
Roll five twenty-sided dice. Subtract 3 from each. Any value now higher than 14 is treated as 14. | Roll five twenty-sided dice. Subtract 3 from each. Any value now higher than 14 is treated as 14. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[t: rollSubWithUpper(5, 20, 3, 14)] | [t: rollSubWithUpper(5, 20, 3, 14)] | ||
</ | </syntaxhighlight> | ||
Returns a number that is between -10 and 70 (and no longer 5 to 100 as with a regular {{code|5d20}} roll). | Returns a number that is between -10 and 70 (and no longer 5 to 100 as with a regular {{code|5d20}} roll). | ||
Latest revision as of 23:59, 14 March 2023
rollSubWithUpper() Function
Generates random numbers to emulate dice rolls. The
sub
parameter is subtracted from each die and all intermediate results that are then higher than the maximum
parameter are replaced with that value instead. The total is returned.Usage
rollSubWithUpper(times, sides, sub, maximum)
Parameters
times
- The number of times to roll the dice.sides
- The number of sides the dice possess.sub
- The number to subtract from each die roll.maximum
- The maximum value (after the subtraction) that each individual die can contribute to the total.
Examples
Roll five twenty-sided dice. Subtract 3 from each. Any value now higher than 14 is treated as 14.
Returns a number that is between -10 and 70 (and no longer 5 to 100 as with a regular
[t: rollSubWithUpper(5, 20, 3, 14)]
5d20
roll).See Also
The corresponding dice roll expression is
XdYsZuW
. For other methods of rolling dice, see Dice Expressions.