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

Initiative Macro Query Not quite working

1627662357

Edited 1627662877
Hey there, first time posting to the forum. Been a Pro member for over a year now, pretty much since the Pandemic broke out, we had to swap our games to online. So I run 2 games currently as DM, sometimes I do One-Shots and other games as well, now all online. I had a pretty good setup when running every game in person. I am a professional digital artist (3D/2D Animation, Illustration, Web Design, Game Design, Video Editing, etc.). So I am a tech enthusiast, I just liked running D&D in person with some digital aides, like my Tablet, Laptop, DnDBeyond, Bluetooth Speakers, etc. I have been playing around with Roll20's Macros as of recently trying to get some things to work that can help me out when I run games. We were using Beyond20 Chrome Extension, but it's recently not been having good results. We now use the Avrae bot with Discord, to do all of the rolling from DnDBeyond straight to Discord to avoid having to buy all the 5e stuff a third time. But I still want to use the Turn Tracker on Roll20. Hence my struggle and this post. I have searched and tried many different things I found online as well as tried mixing and matching, reading the wiki and help for Macros, but it isn't working as I need it to.   My goal is to purely have a Macro for each player that they can select their token , then press the Macro, and have it Query them for " Normal, Advantage, or Disadvantage" , then roll their Initiative accordingly on Roll20 and add them to the turn tracker . I punched all of their initiative bonuses into their Character Sheets on Roll20 and set Bar2 to be the Initiative . The idea being I can just reference Bar2  to use as the modifier. Here is what I have so far: /em @{selected|token_name} rolls a ?{Type of Roll?| Normal, [[1d20+@{selected|bar2}]] |  Advantage, [[2d20k1+@{selected|bar2}]] | Disadvantage, [[2d20kl1+@{selected|bar2}]]} &{tracker} for initiative!  What Happens? Well it asks the question, and the choice does act accordingly. It uses the proper bonus, does the math, says the selected token's name, but it doesn't add it to the turn tracker. I tried this to see if it would work: /em @{selected|token_name} rolls a ?{Type of Roll?| Normal, [[1d20+@{selected|bar2} &{tracker}]] |  Advantage, [[2d20k1+@{selected|bar2} &{tracker}]] | Disadvantage, [[2d20kl1+@{selected|bar2}]] &{tracker}}  for initiative!  But it doesn't. It just breaks, won't even query properly. I tried making nested Macros and Query those. /emas @{selected|token_name} rolls a ?{Type of Roll?| Normal, #Init |  Advantage, #Init-Adv  | Disadvantage, #Init-Dis } for initiative! But that breaks on the Query because each nested macro is using the brackets and commas which will break the syntax.  I'm running out of ideas I was wondering if anyone knew a way to get this concept to work with the method I am trying (using Bar2 as the modifier and adding the selected token to turn tracker).
1627664499
Andreas J.
Forum Champion
Sheet Author
Translator
you cant have the space in front of the # in the query correct way: ?{Choose an Attack| Melee,#str | Ranged,#dex | Magic,#int } <a href="https://wiki.roll20.net/Macro_Guide#Nesting" rel="nofollow">https://wiki.roll20.net/Macro_Guide#Nesting</a>
I was able to get your macro to work when I inserted it into a basic template.&nbsp; A chat message or emote must be the reason why its failing.&nbsp; Wrap it in a simple or default template and you should be gucci.&nbsp;&nbsp;
1627667338
timmaugh
Pro
API Scripter
@DM Eddie, I think you might have tried that on the Dev server, because the OP's original query definitely throws a fit when you try it on the normal servers. The Dev servers have a feature where you don't have to do character replacement for nested queries. @Phildawg - try this one. It was the right braces of your &amp;{tracker} constructions that was your problem. By substituting their HTML equivalents, they don't break the query: /em @{selected|token_name} rolls a ?{Type of Roll?|Normal,[[1d20+@{selected|bar2} &amp;{tracker&amp;rbrace;]]|Advantage,[[2d20k1+@{selected|bar2}; &amp;{tracker&amp;brace;]]|Disadvantage,[[2d20kl1+@{selected|bar2}]] &amp;{tracker&amp;rbrace;} for initiative! Explanation: According to the order of operations , the @{selected} calls are parsed out before the query, so they're long gone by the time the query parsing happens... but the &amp;{tracker} construction is still there. Currently (on non-dev servers), the query thinks it only goes to the first closing brace it sees... so we have to mask those with &amp;rbrace; .
1627667423

Edited 1627667877
timmaugh
Pro
API Scripter
And now I see that you weren't able to get it to the TurnTracker...&nbsp; Hold on. More testing. EDIT: Yep, the above works just fine to get it to the TurnTracker.
So after doing more research and playing around even more I got something to work as I needed with the default template. &amp;{template:default} {{@{selected|token_name}'s Initiative Roll:}} {{Initiative=?{Roll?|Normal, [[1d20+@{selected|bar2} &amp;{tracker&amp;#125;]] |Advantage, [[2d20kh1+@{selected|bar2} &amp;{tracker&amp;#125;]]|Disadvantage, [[2d20kl1+@{selected|bar2} &amp;{tracker&amp;#125;]]}}} So you select the token, Press the Macro, it Queries whether this is Normal, Advantage, or Disadvantage and pending your choice, it performs the proper function as well as adding the token to the turn tracker. This relies on your Bar2 for the token being your initiative bonus , so if you don't want to use that method, you will have to change the @{selected|bar2} to something else. I struggled for hours to find an answer for my needs, I can imagine there are or will be others who want a simple solution for a Query Initiative, so I will leave this post up. Hopefully it can help others If anyone else has an even better way to do this, or one that maybe uses a sleeker template like the&nbsp; D&amp;D 5E by Roll20 , feel free to post it. I would love to try it out. I am working on making this work for a better Template than the default.
1627696461

Edited 1627696697
Oh wow, this definitely didn't update me with all these responses, I thought I was just responding to myself, lol. After I posted my response it didn't show me anyone else's, but just checked my email and saw all of these. @DM Eddie, @timmaugh, and @Andreas J. Thanks so much for all the fast responses. I wish I had seen these earlier. I wound up figuring something out that works and I think its basically what you said timmaugh, I had to replace the right brackets with their HTML equivalents. Although I do notice if I ever open the macro again, it converts the HTML equivalents into regular right brackets so I have to change them all back into the HTML equivalents again if I want it to work. Not huge since I have it set to a token action, so I don't really need to go into the macro for anything, unless I want to try formatting it differently. Oh I wound up changing mine a bit for the 5E template. It does the same thing, but just looks a little nicer: &amp;{template:simple} {{rname=Initiative}} {{mod=@{selected|bar2}}} {{r1=?{Roll?|Normal, [[1d20+@{selected|bar2} &amp;{tracker&amp;#125;]] |Advantage, [[2d20kh1+@{selected|bar2} &amp;{tracker&amp;#125;]]|Disadvantage, [[2d20kl1+@{selected|bar2} &amp;{tracker&amp;#125;]]}}} {{normal=1}} {{charname=@{selected|token_name}}} I couldn't figure out the whole r1 and r2 for Normal/Adv/Dis Query for the 5E by Roll20 Template, but this did the job just fine without it.
Yeah for some reason with the actual sheets, they added some magic or circumvention in the template for advantage/disadv rolls.&nbsp; I just go and grab the full empty template from the wiki whenever I need to make a simple template.&nbsp; The hitting the up arrow in chat on sheets now give you a bogus format when adv/dis is on.&nbsp; I have no idea why r2 doesn't show on sheet rolls properly anymore.&nbsp;&nbsp;
1627738357
Oosh
Sheet Author
API Scripter
Phildawg said: I couldn't figure out the whole r1 and r2 for Normal/Adv/Dis Query for the 5E by Roll20 Template, but this did the job just fine without it. You can't actually use the {{r1}} and {{r2}} fields for an initiative roll anyway - only one value can be sent to the tracker at a time. Out of interest, why are you using bar2 for the initative bonus? You can reference it directly with @{selected|initiative_bonus} to free up bar2 for something else if you'd rather.
To pull off advantage/disadvantage initiative you have to use kh1 or the other lowest.&nbsp;&nbsp;