rollAddWithUpper: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page rollAddWithUpper to RollAddWithUpper without leaving a redirect: Converting page title to first-letter uppercase)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
rollAddWithUpper(times, sides, add, maximum)
rollAddWithUpper(times, sides, add, maximum)
</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:
|examples=
|examples=
Roll five twenty-sided dice. Add 6 to each. Any value now higher than 18 is treated as 18.
Roll five twenty-sided dice. Add 6 to each. Any value now higher than 18 is treated as 18.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[t: rollAddWithUpper(5, 20, 6, 18)]
[t: rollAddWithUpper(5, 20, 6, 18)]
</source>
</syntaxhighlight>
Returns a number that is between 35 and 90 (and no longer 5 to 100 as with a regular {{code|5d20}} roll).
Returns a number that is between 35 and 90 (and no longer 5 to 100 as with a regular {{code|5d20}} roll).



Latest revision as of 22:03, 14 March 2023

rollAddWithUpper() Function

Generates random numbers to emulate dice rolls. The add parameter is added to 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

rollAddWithUpper(times, sides, add, maximum)

Parameters

  • times - The number of times to roll the dice.
  • sides - The number of sides the dice possess.
  • add - The number to add to each die roll.
  • maximum - The maximum value (after the addition) that each individual die can contribute to the total.

Examples

Roll five twenty-sided dice. Add 6 to each. Any value now higher than 18 is treated as 18.
[t: rollAddWithUpper(5, 20, 6, 18)]
Returns a number that is between 35 and 90 (and no longer 5 to 100 as with a regular 5d20 roll).

See Also

The corresponding dice roll expression is XdYaZuW. For other methods of rolling dice, see Dice Expressions.