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

Is there a way to query a number of times to repeat a line?

So I have this line [[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]] And I want a query at the end, like ?Repeat this line X number of times. So that I can input the advantage, attack bonus, and then tell it how many rolls to make. Is that possible? Thanks!
1585719269
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I do not believe so. It would require either the API, or a sheet with a custom roll template. Macros do not handle conditional logic or looping. They are less a programming language and more of a fancy die roller.
1585720142

Edited 1585722088
GiGs
Pro
Sheet Author
API Scripter
The only way to do this with out the API is very clunky. You have to account for exactly how many entries might be allowed, and write a different line in the query that includes all the roll elements repeated that many times. And you will have to learn how to use html entities. So that would look something like this (this wont work, because I havent entered the necessary html substitutions, but the structure is correct): ?{How many Attacks?| 1,[[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]]| 2,[[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]] [[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]]| 3,[[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]] [[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]] [[ ?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Attack Bonus|1} ]]} If they are all the same type (standard, etc) you can pull that query out, like so !?{Attack Type|Standard, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1} ?{How many Attacks?| 1,[[ ?{Attack Type}+?{Attack Bonus|1} ]]| 2,[[ ?{Attack Type}+?{Attack Bonus|1} ]] [[ ?{Attack Type}+?{Attack Bonus|1} ]]| 3,[[ ?{Attack Type}+?{Attack Bonus|1} ]] [[ ?{Attack Type}+?{Attack Bonus|1} ]] [[ ?{Attack Type}+?{Attack Bonus|1} ]]} If they aren't all the same, you'll have give each attack type query a different name to ensure they are treated separately. You'll still need to substitute key characters with html entities as described here Honestly, it's much easier just to click your macro as many types as you need.
Oof. Yeah, it doesn't do me any good if i have to repeat the values for each individual roll. It would only be good if I could define the roll, and then repeat the defined roll. it seems like it should be such a simple command (opening symbol <defined roll> closing symbol) ?Repeat# or something. they do so many more complicated things with macros here, im surprised this doesnt exist. i'm terrible at writing code, but ive made windows hotkeys for this much. Oh well, thanks anyways guys
1585721926
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I forgot the brute force iteration approach.
Or alternatively some kind of X = ? , Y = ?, and  then have 8 attacks written out that all accept the input of X or Y. i guess that would work. maybe i can do that making a custom NPC sheet and just editing attributes.
Don't forget that once you execute that, you can click in the chat box, push the up arrow key, then press the Enter key and it will re-execute the roll.