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

Using a macro to roll multiple times

Okay, so, I'm back once again with a question on writing macros. I was wondering if it were possible to make a macro that asks how many times you want to roll it, and then takes that number and somehow rolls something multiple times. I tried something like this:
This is the roll: 1d20+3
This is the macro I tried:
[[1d20+3]]*?{How many times do you need to roll it(insert a number)}

And it just multiplies whatever the roll outputs times the number you input. I did find a work around by doing something like this:
?{How many times do you need to roll it|1,[[1d20+3]]|2,[[1d20+3]][[1d20+3]]|....}
bit that limits how many times you can roll. I need this macro because we have spells like shatter, that require lots of enemies to roll a saving throw. These are simplified versions of the macros.
October 29 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You can simply do this:

[[?{Roll How many times}d20+3*?{Roll How many times}]]

It will however give you the total for all the rolls rather than rolling separately.

There isn't a way to roll separately a dynamic number of times.
Ah. Alright, thanks for your help then, I appreciate it. I've also been trying to find a way to get roll templates to work with hidden rolls.

!?{Which Check will you use?|Wisdom, @{Selected|Wisdom|max} |Intelligence, @{Selected|Intelligence|max} |Dexterity, @{Selected|Dexterity|max} |Charisma, @{Selected|Charisma|max} | Constitution, @{Selected|Constitution|max} |Strength, @{Selected|Strength|max}} ?{With Proficiency?|Double,@{Selected|Proficiency|max}*2|Yes,@{Selected|Proficiency|max}|No,+0}?{Do you have advantage?| Yes, 2d20kh1 | No, 1d20}
&{template:default}{{name=?{What is the name of the check?} Check}}{{[[ ?{Do you have advantage?}?{Which Check will you use?}?{With Proficiency?}]]}}


That is an example of one way I've been trying to get it to work, but it never wants to output correctly. Is it just not possible to get the hidden roll to register within the template?
October 29 (7 years ago)
If you're just trying to make a bunch of saving throw rolls, assuming all of the enemies have the same modifier and target DC, could you use the following work-around?

[[?{Number of times}d20>?{DC}]]

Instead of adding in the +3 to the roll, just subtract 3 from the DC for the saving throw. So if you want them to make a 1d20+3 against a 17, just use 1d20 vs a 14. It will output the number of successful checks that were made. You can also look at the individual rolls.

This obviously won't work for any situations that are more complicated though.

October 29 (7 years ago)

Edited October 29 (7 years ago)
Yeah, I think I'm gonna stick with just copying the rolls and using a selection query
?{How many times do you need to roll it|1,[[1d20+3]]|2,[[1d20+3]][[1d20+3]]|....}
Because I wanted each roll to be visible as it's own roll. Not efficient, but it works for what I wanted. You have any ideas on how to get that other macro to work with the templates?

EDIT:
Nevermind, I can just place the actual attribute rolls into the template instead of hiding it and then using query substitution 
October 30 (7 years ago)

Edited October 30 (7 years ago)

Nathaniel S. said:

?{Do you have advantage?}?{Which Check will you use?}?{With Proficiency?}

The issue is that the above needed to be rewritten as ?{Do you have advantage?}+?{Which Check will you use?}+(?{With Proficiency?})

Here's my recommendation:
! ?{Which Check will you use?|
   Wisdom, @{Selected|Wisdom|max} |
   Intelligence, @{Selected|Intelligence|max} |
   Dexterity, @{Selected|Dexterity|max} |
   Charisma, @{Selected|Charisma|max} |
   Constitution, @{Selected|Constitution|max} |
   Strength, @{Selected|Strength|max} 
} ?{With Proficiency?|
   Double, @{Selected|Proficiency|max} * 2 |
   Yes, @{Selected|Proficiency|max} |
No, 0 } ?{Do you have advantage?|    Yes, 2d20kh1 |    No, 1d20 } &{template:default} {{name=?{What is the name of the check?} Check}} {{[[ ?{Do you have advantage?} + ?{Which Check will you use?} + ?{With Proficiency?} ]]}}
October 30 (7 years ago)

Edited October 30 (7 years ago)

Nathaniel S. said:

Okay, so, I'm back once again with a question on writing macros. I was wondering if it were possible to make a macro that asks how many times you want to roll it, and then takes that number and somehow rolls something multiple times. I tried something like this:
This is the roll: 1d20+3
This is the macro I tried:
[[1d20+3]]*?{How many times do you need to roll it(insert a number)}

And it just multiplies whatever the roll outputs times the number you input. I did find a work around by doing something like this:
?{How many times do you need to roll it|1,[[1d20+3]]|2,[[1d20+3]][[1d20+3]]|....}
bit that limits how many times you can roll. I need this macro because we have spells like shatter, that require lots of enemies to roll a saving throw. These are simplified versions of the macros.
I have a power card macro that rolls 4 dice of the type I choose and a custom one. I use what i need so if I need 3d8 I just add the 3. If I need 5 i roll it twice. This does have a mod to add +/- but you can easily add that with a query. I add the Modifier query for you.
 


!power {{
--whisper|GM
--corners|10
--titlefontshadow|none
--titlebackground|none
--titlefont|Comic sans MS
--format|Dice
--name| GM Dice Roller
--leftsub|For all the GM's Needs
--Type of dice Rolling:|[[8]]
--Modifier:|[[(?{Modifiers})]]
--Rolled:| [[1d8 + ?{Modifiers}]] | [[1d8 + (?{Modifiers})]]  | [[1d8 + (?{Modifiers})]] | [[1d8 + (?{Modifiers})]]

}}
this was rolled 1d8+10 4 times


You would need a pro account and powercard API. Its all worth it. Your player could use this as well if you needed.

October 31 (7 years ago)

Edited October 31 (7 years ago)

Silvyre said:


The issue is that the above needed to be rewritten as ?{Do you have advantage?}+?{Which Check will you use?}+(?{With Proficiency?})
Each of the abilities for the characters have a built in + or - modifier in the "max" field of their stats, and I have proficiency in the stats as well, so the plusses will actually break my macro. But I will see if your recommendation code works w/o the plusses. Thanks.

EDIT:
Huh. Your code without the extra plusses is just the same as mine, yet it worked. I went back and re-tried mine, and it worked as well. I wonder why it wasn't working before...Ah well. Anyways, thanks for the help!