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

Nesting Macros, nested macros not responding correctly?

I'm trying to help a player out with macros to make things easier. He has a barrage attack (Spheres of Might) that let's him shoot 2, 3, 4, or 5 shots off, each for a different penalty to hit. I have a basic macro that is ?{How Many Attacks?|2,#barrage2 |3,#barrage3 |4,#barrage4 } Which works fine if I have barrage2 macro just set up as like "2" or something to know I have the correct output. If you press the up arrow after someone uses an attack of spell, you get all the text needed to reproduce that attack in a macro. I can make an attack under Weapons/Attacks and that works fine. I can copy + paste that into a macro and that macro works fine. I call this macro barrage2. But when I try to nest barrage2 in Barrage now, I no longer get the option to select 2, 3, or 4. I get Input Value: How Many Attacks? and get prompted with"2, &{template:pc" and can't select any values anymore. If I just type 2, it runs the macro for barrage2 but with "2" at the front of it, so it is no longer recongized as code. I know I can just run a few roll commands and add text to say "this is the to-hit" and "this is the damage" but I really like having everything formatted if possible, since the attacks also do a few nice things like adjust to any buffs the player turns on/off and rolls critical confirmations.
<a href="https://wiki.roll20.net/Roll_Query/Nested" rel="nofollow">https://wiki.roll20.net/Roll_Query/Nested</a> <a href="https://wiki.roll20.net/Order_of_Operations" rel="nofollow">https://wiki.roll20.net/Order_of_Operations</a> If the #barrage2 macro has any query 'control' characters ( | , } ) then what happens is Roll20 will first substitute #barrage2 into the Barrage query, and those characters 'break' the Barrage query because Roll20 sees the control character from #barrage2 and thinks that the characters belong to 'Barrage'. The workaround is to use html replacements in the #barrage2 macro Comma: , = &amp;comma; Right Brace: } = &amp;rbrace; Vertical Pipe: | = &amp;vert; If you save any html replacements in a Collections Macro, the caveat is that they will be parsed (replaced by their regular characters) if you ever open the macro again in the future.&nbsp; You can avoid that by putting them in an Ability on a character sheet, and calling that from a Collections Macro. The other option is to use a chat menu &nbsp;instead of a nested query.
1688764524
GiGs
Pro
Sheet Author
API Scripter
To add to jarren's excellent post, I'd say: never nest queries, always use chat menus (where possible). Your original macro as a chat menu would look like this &amp;{template:default} {{name=Choose How Many Barrages}} {{[2 Barrages](`#barrage2) |&nbsp;[3 Barrages](`#barrage3) |&nbsp;[4 Barrages](`#barrage4) }} That would place the 3 buttons in chat, like this: You could whisper it to the player, so only they see the buttons. /w "NAME" &amp;{template:default} {{name=Choose How Many Barrages}} {{[2 Barrages](`#barrage2) |&nbsp;[3 Barrages](`#barrage3) |&nbsp;[4 Barrages](`#barrage4) }} Replace NAME with either a player name, character name, or token name. (and you can use /w @{selected|character_name} if it only works when a token owned by a character is selected). Give that macro to the player in question, and they'll be able to use those macros.
1688768799
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
GiGs said: To add to jarren's excellent post, I'd say: never nest queries, always use chat menus (where possible). Thirding this. It's just substantially less headache. Combining&nbsp; Chat Menus &nbsp;with a&nbsp; Macro Character Sheet &nbsp;is an extremely robust workflow, allowing you to simplify code, centralize automation, re-use macros across games.
I wasn't try to nest queries. At least I didn't think I was. It was suppose to be choose attack number -&gt; macro to roll attacks. Also I didn't know about chat menus. That is amazing and I thank you for that.
1688781414
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Brandon S. said: I wasn't try to nest queries. At least I didn't think I was. It was suppose to be choose attack number -&gt; macro to roll attacks. Also I didn't know about chat menus. That is amazing and I thank you for that. Sorry for the diversion, if you weren't trying to nest queries. But it's such a common error that we pretty much jump in that direction.
You got me a solution and that's all I could ask for. I don't expect anyone to look at the entire code for the attack page and figure out what is wrong.
1688801443

Edited 1688801487
GiGs
Pro
Sheet Author
API Scripter
Brandon S. said: I wasn't try to nest queries. At least I didn't think I was. I should have been more specific. I meant never do this: ?{How Many Attacks?|2,#barrage2 |3,#barrage3 |4,#barrage4 } Basically, never use a query when you put yourself in a situation where you can't immediately see what the macro contains, because you might end up having to use HTML entities and ruin the macro you are calling. Always use a chat menu in these cases. Also, never use HTML Entities, if you can avoid it. Again, chat menus will usually fix those situations.