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

Rolling multiple sets of dice at once in a script or a macro

Hey, I'm completely new to the roll20 API and I'm trying to work on some things for my DM to help him run some mass combat. I have a specific example, as part of a battle, an airship will roll 50 attacks with disadvantage. In the macro I know I can do [[{100d20kl50}>@{target|ac}]] or something along those lines, but that wouldn't be statistically fair for the airship (I tested this against another airship with 20AC 5 times, in each case 0 attacks hit the other airship). I thought of doing [[2d20kl1>@{target|ac}]] 50 times, but obviously this would spam the chat and the DM would have to count up all the hits. Is there any way to roll 50 lots of [[2d20kl1>@{target|ac}]] within roll20 macros or using the API? If it is the case with the API, how would one go about implementing it?
1593985167
The Aaron
Roll20 Production Team
API Scripter
You can do it in the API. I can help with that in 3–5 days, but I'm without a computer for now.  The basic idea would be to build a string containing the inline roll repeated 50 times and pass it to sendChat() with a callback, then collect all the results and report back. 
The Aaron said: You can do it in the API. I can help with that in 3–5 days, but I'm without a computer for now.&nbsp; The basic idea would be to build a string containing the inline roll repeated 50 times and pass it to sendChat() with a callback, then collect all the results and report back.&nbsp; Thanks! I really appreciate the offer, I'd be happy to take you up on it whenever you're free. In the meantime, I'll try teaching myself some JavaScript and have a crack at it. The resource I've found for API functions is this: <a href="https://roll20.zendesk.com/hc/en-us/articles/360037256754-API-Chat#API:Chat-chat:message" rel="nofollow">https://roll20.zendesk.com/hc/en-us/articles/360037256754-API-Chat#API:Chat-chat:message</a> Is that still up to date to your knowledge, or would you recommend a different resource? Thanks again!
1594063943
The Aaron
Roll20 Production Team
API Scripter
That's up-to-date as a reference to the function. For learning to write APIs, here's my standard spiel: Javascript for Cats is a nice refresher for JS:&nbsp; <a href="http://jsforcats.com/" rel="nofollow">http://jsforcats.com/</a> &nbsp; I also recommend the book "Javascript: The Good Parts" by Douglas Crockford.&nbsp; It's an older book, but a great foundation. &nbsp; (Pre-javascript ES6, but you can learn those differences after.) Here are some Roll20 specific Forum links: <a href="https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern" rel="nofollow">https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern</a> <a href="https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1</a> <a href="https://app.roll20.net/forum/post/6237754/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6237754/slug%7D</a> Also, Nick Olivo has some nice videos about writing API scripts:&nbsp; <a href="https://www.youtube.com/user/NicholasOlivo/playlists" rel="nofollow">https://www.youtube.com/user/NicholasOlivo/playlists</a>