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

Simplicity Programmed Challenge: Programmably Easy Dice Rolls

function Roll (stringDiceRollFormula){     var numberDiceRollResult;         <<< CHALLENGE :  WHAT GOES HERE? >>>     return numberDiceRollResult; }; One of the great things about Roll20 that I have discovered is the dice rolling engine.  Unfortunately, this is not available with a single, simple JS function.  Why not?  Seriously, why is this not so?  The simplest of codes that I have found either pass around entire message objects instead of a number result, or are not able to pass the final number result due to (I'm guessing) nested function definitions embedded within parameters of other functions forcing me to do my programming within that nested, embedded function thus forcing me to copy entire blocks of code for something that should be an extremely-simple, one-line function call.   So, what I'm looking for is a way to program this once in a function that I could easily call again and again in my scripts, take the results and do whatever I want with them at any point.  Wouldn't it be nice to just code the following in our Java scripts? var Str = Roll("4d6k3"); var Dex = Roll("4d6k3"); var Con = Roll("4d6k3"); var Int = Roll("4d6k3"); var Wis = Roll("4d6k3"); var Cha = Roll("4d6k3");
1586395417
The Aaron
Roll20 Production Team
API Scripter
You do it like this: sendChat('',someDiceFormula,(rolls)=>{ /* do stuff with rolls[0] */ }); It's an asynchronous call, so you have to deal with callbacks.
1586422600
GiGs
Pro
Sheet Author
API Scripter
Assuming you can get it working. See this bug, confirmed by Nicholas:&nbsp; <a href="https://app.roll20.net/forum/post/8118995/there-was-an-error-communicating-with-the-quantumroll-server-undefined-on-dev-system-including-custom-sheet-sandbox/?pageforid=8407353#post-8407353" rel="nofollow">https://app.roll20.net/forum/post/8118995/there-was-an-error-communicating-with-the-quantumroll-server-undefined-on-dev-system-including-custom-sheet-sandbox/?pageforid=8407353#post-8407353</a>