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

Nested Query Question

Trying to implement a nested query and running into some trouble.  Tried following the example from the wiki and from what I could find in a couple other threads, but I'm not seeing my error.   /roll ?{4+ Crew shooting?|      Yes,?{Cover?|           No,3t[AttackDice3+] + (?{Number of Crew Shooting}-3)t[AttackDice4+]|           Yes,3t[AttackDice4+] + (?{Number of Crew Shooting}-3)t[AttackDice5+]}|      No,?{Cover?|           No,?{Number of Crew Shooting}t[AttackDice3+]|           Yes,?{Number of Crew Shooting}t[AttackDice4+]}} Any help would be appreciated!
1605939181
Oosh
Sheet Author
API Scripter
I think you're going to have to escape the ampersands in the 3rd layer of nesting, or the } will break the 2nd layer of nesting. Thusly: /roll ?{4+ Crew shooting?| Yes,?{Cover?| No,3t[AttackDice3+] + (?{Number of Crew Shooting}-3)t[AttackDice4+]| Yes,3t[AttackDice4+] + (?{Number of Crew Shooting}-3)t[AttackDice5+]}| No,?{Cover?| No,?{Number of Crew Shooting}t[AttackDice3+]| Yes,?{Number of Crew Shooting}t[AttackDice4+]}} ... are you serving penance for some heinous crime?
Thank you;  that works like a charm! But I'm very confused...  Why does the ampersand in }  break the nesting but the ampersand in }  not break it?
1605970342

Edited 1605970805
Oosh
Sheet Author
API Scripter
Because "}" can't be  isn't parsed in one go by R20, it's an extra iteration the parser has to make to pick up the } character. So on the first pass it'll pick up the & and turn it into a &. It ignores the #125; because it didn't start with a & on this pass. The next pass will pick up the } and turn it into a }. That extra step means on the third pass, it finally picks up that"Number of crew" Query and the } ending it - but by that third pass, it's resolved the two outer Queries. Without the extra step to substitute the &, the parser will pick up that } on the second iteration while it's dealing with the ?{Cover? Yes/No} Query, ending that Query early. We need it to still be a } at that stage, so the parser keeps reading through the -3)t[Attackdice5+] and gets to the next }... which is already a } brace, because its ampersand wasn't escaped so it's resolved one iteration earlier. Clear as mud? :) Sorry, not very good at explaining. Probably needs a GiGs or Aaron lecture. Here's the Order of Operations . The second sentence in step 5 is the relevant one... it's probably clearer than all my babble above.
Huh -- thank you for the explanation!  That makes a lot of sense.  More importantly, it makes my macro work, so my thanks for the help!