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 macro/ability in a query issue

1682678931

Edited 1682679234
So I've been trying to nest a macro within a query for about 2 hours now. Obviously it expands the macro within the query when it tries to parse it, so I've replaced all the syntax with HTML entities and I've turned the macro into a character ability and I'm instead trying to call the ability in the query. The problem I'm currently having is, when I try to call the ability in the query, literally nothing happens. No error, no output. When I manually use the ability, it outputs the raw text of the macro (converting HTML entities to their correct form), without actually parsing it properly, but if I ctrl+c then ctrl+v that raw text into the chat, it will roll the macro correctly, so the code is clearly working fine. I'm just at such a loss right now. Any help would be so greatly appreciated. For reference, heres the macro (ability) I'm trying to call in the query (with and without HTML entities) With HTML entities & #38;& #123;template:atkdmg& #125; & #123;& #123;mod=& #91;& #91;3+& #64;& #123;Do'dreg 'The Admiral'& #124;strength_mod& #125;+& #64;& #123;Do'dreg 'The Admiral'& #124;pb& #125;& #93;& #93;& #125;& #125; & #123;& #123;rname=Legendary Greatsword 0& #125;& #125; & #123;& #123;r1=& #91;& #91;1d20+& #64;& #123;Do'dreg 'The Admiral'& #124;strength_mod& #125;+& #64;& #123;Do'dreg 'The Admiral'& #124;pb& #125;& #93;& #93;& #125;& #125; & #123;& #123;always=1& #125;& #125; & #123;& #123;r2=& #91;& #91;1d20+& #64;& #123;Do'dreg 'The Admiral'& #124;strength_mod& #125;+& #64;& #123;Do'dreg 'The Admiral'& #124;pb& #125;& #93;& #93;& #125;& #125; & #123;& #123;attack=1& #125;& #125; & #123;& #123;damage=1& #125;& #125; & #123;& #123;dmg1flag=1& #125;& #125; & #123;& #123;dmg1=& #91;& #91;2d6+3+& #64;& #123;Do'dreg 'The Admiral'& #124;strength_mod& #125;& #93;& #93;& #125;& #125; & #123;& #123;dmg1type=Slashing& #125;& #125; & #123;& #123;crit1=& #91;& #91;2d6& #93;& #93;& #125;& #125; & #123;& #123;globalattack=& #64;& #123;Do'dreg 'The Admiral'& #124;global_attack_mod& #125;& #125;& #125; & #123;& #123;globaldamage=& #91;& #91;& #64;& #123;Do'dreg 'The Admiral'& #124;global_damage_mod_roll& #125;& #93;& #93;& #125;& #125; & #123;& #123;globaldamagetype=& #64;& #123;Do'dreg 'The Admiral'& #124;global_damage_mod_type& #125;& #125;& #125; Without HTML entities &{template:atkdmg} {{mod=[[3+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{rname=Legendary Greatsword 0}} {{r1=[[1d20+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{always=1}} {{r2=[[1d20+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[2d6+3+@{Do'dreg 'The Admiral'|strength_mod}]]}} {{dmg1type=Slashing}} {{crit1=[[2d6]]}} {{globalattack=@{Do'dreg 'The Admiral'|global_attack_mod}}} {{globaldamage=[[@{Do'dreg 'The Admiral'|global_damage_mod_roll}]]}} {{globaldamagetype=@{Do'dreg 'The Admiral'|global_damage_mod_type}}} Then this is the code for the query macro ?{Number of Charges? | 0,%{Do'dreg 'The Admiral'|Legendary-Greatsword-0} | 1,1| 2,2| 3,3} TL;DR HTML entity macro outputs raw text into chat instead of parsing it as if it were a macro, halp
1682681485
timmaugh
Forum Champion
API Scripter
I think you have a space after all of your ampersands. For example, it should be: } ...not & #125; However, if you have scripts available, you could do this with Fetch and ZeroFrame and not have to do any replacements at all. You could leave the ability as is, so that you could run it from the sheet and have it run (instead of seeing the raw text), *and* it would work in the query, too. ! ?{Number of Charges? | 0,%(Do'dreg 'The Admiral'.Legendary-Greatsword-0) | 1,1| 2,2| 3,3}{&simple}
Yeah, I did that specifically for the post becuase I thought the forums would turn the } into a }, but apparently it doesn't by the looks of it lol
1682683518
timmaugh
Forum Champion
API Scripter
Ahh... Also, if you don't want to go the route of metascripts, and if you don't want to go the route of a  Chat Menu  (with a button to run the source ability), you might also look at the fact that the only characters you need to escape to nest it in a query are the characters that will break a query: }    =>   } |    =>   | ,    =>   , You don't want to escape your @ for an attribute call (to be @) unless you want the @ to appear in the output . If you want it to be used to resolve/expand an attribute, you need it in there. This is because according to the order of operations , attributes are resolved before queries, so the html replacement value will not be un-escaped in time for the attribute to resolve. The query will run and the value will unescape, but by then the attributes have already resolved.
1682684088
Ziechael
Forum Champion
Sheet Author
API Scripter
You only need to escape problematic characters ( } | and , ) outside of attribute calls: &{template:atkdmg} {{mod=[[3+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]} }  {{rname=Legendary Greatsword 0 } }  {{r1=[[1d20+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]] } }  {{always=1 } }  {{r2=[[1d20+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]] } }  {{attack=1 } }  {{damage=1 } }  {{dmg1flag=1 } }  {{dmg1=[[2d6+3+@{Do'dreg 'The Admiral'|strength_mod}]] } }  {{dmg1type=Slashing } }  {{crit1=[[2d6]] } }  {{globalattack=@{Do'dreg 'The Admiral'|global_attack_mod} } }  {{globaldamage=[[@{Do'dreg 'The Admiral'|global_damage_mod_roll}]] } }  {{globaldamagetype=@{Do'dreg 'The Admiral'|global_damage_mod_type} } } It is also good practice to only nest the points of divergence too... if the template call is always the same, for example, you can use: &{template:atkdmg}  ?{Number of Charges? | 0,%(Do'dreg 'The Admiral'.Legendary-Greatsword-0) | 1,1| 2,2| 3,3}{&simple} And just drop  &{template:atkdmg} from the front of each query result.
I did originally only replace } with the HTML code, but then it started throwing out errors about finding @'s where they shouldn't be, then when I replaced the @'s it started complaining about &'s, so i just replaced everything with HTML code. But I've come up with a much more elegant solution for my problem! I've moved the query to inside of the original macro and did some annoying maths to make it work. So issue is all sorted now. Thanks for the help though! This is the final product if anyone was interested. It's for the Greatsword from the Monster Hunter ruleset by Amellwind &{template:atkdmg} {{mod=[[3+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{rname=Legendary Greatsword}} {{r1=[[1d20+3+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{always=1}} {{r2=[[1d20+3+@{Do'dreg 'The Admiral'|strength_mod}+@{Do'dreg 'The Admiral'|pb}]]}} {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[?{Number of Charges?| 0,0| 1,1| 2,2| 3,3}d10+2d6+3+(@{Do'dreg 'The Admiral'|strength_mod}*(?{Number of Charges?}+1))+({-1+?{Number of Charges?},[[0d1]]}kh1)*3]]}} {{dmg1type=Slashing}} {{crit1=[[?{Number of Charges?}d10+2d6]]}} {{globalattack=@{Do'dreg 'The Admiral'|global_attack_mod}}} {{globaldamage=[[@{Do'dreg 'The Admiral'|global_damage_mod_roll}]]}} {{globaldamagetype=@{Do'dreg 'The Admiral'|global_damage_mod_type}}}
It is also good practice to only nest the points of divergence too... if the template call is always the same, for example, you can use: &{template:atkdmg}  ?{Number of Charges? | 0,%(Do'dreg 'The Admiral'.Legendary-Greatsword-0) | 1,1| 2,2| 3,3}{&simple} And just drop  &{template:atkdmg} from the front of each query result. This is actually such a good point and I'm annoyed I didn't consider it tbh. I'm 100% using that tech in the future when I need to query a macro again.
1682684568
Ziechael
Forum Champion
Sheet Author
API Scripter
SwagVozhd said: ...some annoying maths to make it work. So issue is all sorted now.  Never has the nested query argument been so perfectly summarised! It truly is a balance between html replacement headaches and mathematical headaches... glad you got it sorted though, it is a dark world with a steep learning curve you have entered ;) Happy rolling!