User Tools

Site Tools


modding:function:rolldice

Discuss this page on this page's Talk Page

rollDice

See rollDice at Xelerus

Syntax (rollDice number sides [bonus]) → result
Arguments number: The number of dice you want to roll.
sides: The number of sides you want each of the dice to have.
[bonus]: Optional. A bonus that is added at the end.
Returns result: A random number made from “rolling” that many dice and adding them together then adds the bonus.
Category random
Description Returns a random number made from “rolling” that many dice and adding them together then adds the bonus.

Very useful function for making variation in code. It is basically just a helper function for random.

Example

(rollDice 1 6 10)

Returns a number between 11 and 16.

(setq twodice (rollDice 2 6))
(if (eq twodice 2)
   (plyMessage gPlayer "Snake Eyes!")
   (plyMessage gPlayer (cat "You rolled a " twoDice))
)

Simulates rolling two six sided dice.
Returns “You rolled a NN” (for NN between 3 and 12) or “Snake Eyes!” (if you roll a double one).

Return to Functions list

modding/function/rolldice.txt · Last modified: 2014/12/27 04:40 by 127.0.0.1