Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Dice Function?

Does the API have a pre-made dice function of some sort or are we stuck using something like this function I've been using: function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } Can anyone tell me if there is a dice rolling function built into the API?
randomInteger(100) or whatever the dice number is in the parentheses. This doesn't roll dice in game though, and mousing over an output won't show the dice type. Maybe there's a way for that, but this is what I've been using.
1525831949

Edited 1525831987
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Also, of note. This uses the same quantumroll as doing a dice roll in chat. I'd recommend giving the API wiki a thorough read
1525833235
The Aaron
Pro
API Scripter
In truth, Math.random() in the api is backed by the same thing as randomInteger(), but the latter is preferred. You can also send formulas to sendChat() and use the callback to get their result.