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 .
×

Repeating Macro

Is there a way to repeat a macro more than once?  I'm trying to write a macro for D&D 5th where multiple attackers are assailing a target and they all have disadvantage.  Ideally, the macro should: 1. Ask for the number of attackers 2. Ask for the target armor class 3. Roll with disadvantage a number of times equal to the number of attackers 4. Compare the result with the target armor class 5. Report the number of successes This is what I have so far. ?{ArmorClass|0} /roll ?{Attackers|0}[[{2d20KL1>?{ArmorClass}}]] Unfortunately, all this does is roll with disadvantage once.  It doesn't repeat in accordance with the number of attackers.
1469895259

Edited 1469895606
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I think you'd need to do something like: ?{ArmorClass|0} /roll ?{Attackers|1,[[{2d20KL1>?{ArmorClass &#124 0 &#125 }]] | 2, [[{2d20KL1>?{ArmorClass &#124 0 &#125 }]] [[{2d20KL1>?{ArmorClass &#125 }]] | ... | n, [[{2d20KL1>?{ArmorClass &#124 0 &#125 }]]repeating n-1 times as [[{2d20KL1>?{ArmorClass &#125 }]]} I'm not aware of a way to have the game roll a set of dice multiple number of times other than just entering the dice multiple times. Also, make sure you do html entity replacement for the ending bracket in the ?{ArmorClass} calls inside the query as shown above. EDIT: you can also get rid of the ?{ArmorClass|0} call at the start, and just incorporate it into the roll, unless of course you want it separated out. I'm also not sure that you want to use the success/fail syntax as your rolls will just show as 0 or 1 (fail vs success).
1469895346
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Also, you don't need the "/roll" in the macro since you are using inline rolls.
Another way to accomplish this might be to use Command Buttons. e.g. [AC ?{ArmorClass|0}](!
 [[ 2d20KL1>?{ArmorClass} ]]) As Scott demonstrated,  Advanced Roll Queries might be your best bet. Here's my own: /r [vs. AC ?{AC|10}:] { ?{Attackers| 1, 2d20kl1 | 2, 2d20kl1, 2d20kl1 | 3, 2d20kl1, 2d20kl1, 2d20kl1 | 4, 2d20kl1, 2d20kl1, 2d20kl1, 2d20kl1 } }>?{AC}
1469895817

Edited 1469895895
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Silvyre said: Another way to accomplish this might be to use Command Buttons. e.g. [AC ?{ArmorClass|0}](! [[ 2d20KL1>?{ArmorClass} ]]) HTML entities above converted by forum parser. Will the roll query carry across from the button's label to the button's command? I always thought the command resolved as essentially another chat message.
Scott C. said: Will the roll query carry across from the button's label to the button's command? Yup. I always thought the command resolved as essentially another chat message. The Roll Query within the API Command Button isn't escaped, so the Query is resolved before the ACB is parsed (which is after the standard Order of Operations ).
1469930249
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, very cool.
Awesome!  Works great.  Thanks for your help!