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

Calling to a Roll Query within the same macro

Hey there roll20 folks. I'm using the 5e macro template to create a healing potion macro for my players. The macro is as follows: &{template:simple} {{rname=Healing Potion}}{{mod=used}}{{r1=?{Potion Type|Regular, [[2d4+2]]|Greater, [[4d4+4]]|Superior, [[8d4+8]]|Supreme, [[10d4+20]]}}}{{always=1}}{{r2=HP Recovered}}{{charname=@{selected|token_name}}} The {{mod=used}} portion is just a placeholder. I would like to add the final touch to this macro by having that {{mod}} section show the selection made from the roll query, not the dice roll but the name. For example, if "Regular" is selected from the query then I want the {{mod}} section to read "Regular". I hope this makes sense. I would appreciate any input. Thank you.
1590308975
GiGs
Pro
Sheet Author
API Scripter
The only way to do this is pretty complex. You'll need to use html entity substitutions as described here:&nbsp; <a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a> And you'll need to construct the macro a bit differently. Replace this {{mod=used}}{{r1=?{Potion Type|Regular, [[2d4+2]]|Greater, [[4d4+4]]|Superior, [[8d4+8]]|Supreme, [[10d4+20]]}}} with something like this {{r1=?{Potion Type| Regular, [[2d4+2]] }}{{mod=Regular| Greater, [[4d4+4]]&nbsp;}}{{mod=Greater| Superior, [[8d4+8]]&nbsp;}}{{mod=Superior| Supreme, [[10d4+20]]&nbsp;}}{{mod=Supreme } }} The above code wont work yet. The trick is, there's no way in roll20 for a query to save previous results, so the only way to do this is to include more of the macro inside each row of the query.&nbsp; The problem is, you cant use }} brackets inside a query - the query thinks an } marks the end of the query so the macro ends prematurely. So what you need to is change the } symbol to its html entity: that fools the macro into ignoring it, but it gets printed to chat as an }. From the page linked above, we learn that the html entity for } is&nbsp; &amp;#125; , so we substitute that where needed above. {{r1=?{Potion Type| Regular, [[2d4+2]] &amp;#125;&amp;#125;{{mod=Regular| Greater, [[4d4+4]]&nbsp;&amp;#125;&amp;#125;{{mod=Greater| Superior, [[8d4+8]]&nbsp;&amp;#125;&amp;#125;{{mod=Superior| Supreme, [[10d4+20]]&nbsp;&amp;#125;&amp;#125;{{mod=Supreme } }} Notice that i put the }} for the {{mod}} section after the end query bracket, to reduce the number of html entities. If the text you want to include in the {{mod}} includes certain special characters (commas or pipes | basically), they will need replacing to0, because they have a specific meaning in queries. IMPORTANT: &nbsp;If this is saved as a macro &nbsp;you must never reopen it. Once you open it, all the html entities will be converted to }} characters, and the macro will break. If you save it is a character ability &nbsp;that doesn't happen. So where possible, save things like this as character abilities.
Got it, I will test this out and report back, thank you!