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

Query inside a query?

October 06 (8 years ago)
I want to do this a macro where I can use different weapons with a single macro. Something like:
?{Weapon|Maul,%{Rising Claw|Maul}|Spear 1 Hand, %{Rising Claw|Spear 1 Hand|Spear 2 Hand, %{Rising Claw|Spear 2 Hand}}
The Abilities have templates and queries themselves and it seems that this is where I am getting the problem.

The abilities all are similar to the one that follows. Is there a way to make this work?

,&{template:npcaction} {{rname=LOA'IL-IAGO (Maul)}} {{name=?{Flavor|A mighty strike!| A mighty strike filled with fury!|A mighty strike filled divine energy!|A mighty strike filled with divine fury!}}} {{description=?{Reckless|No, • Not Reckless|Yes, • Reckless}
?{Sacred Weapon|Yes, • Attack [[1d20+@{strength_mod}+@{charisma_mod}+@{PB}]] - [[1d20+@{strength_mod}+@{charisma_mod}+@{PB}]]
 • Counts as Magical| No, • Attack: [[1d20+@{strength_mod}+@{PB}]] - [[1d20+@{strength_mod}+@{PB}]]}


?{Rage|Yes, • Damage: [[2d6ro<2 +@{strength_mod}+2]]
+ [[2d6ro<2]] on Crits|No, • Damage: [[2d6ro<2 +@{strength_mod}]]
+ [[2d6ro<2]] on Crits}
Bludgeoning Damage


?{Smite|No,  • No Smite Bonus|1st Level Spell Slot, • Smite: [[2d8]] Radiant Damage
+ [[2d8]] on Crit
+ [[1d8]] if Undead or Fiend
+ [[1d8]] on Crit|2nd Level Spell Slot, • Smite: [[3d8]] Radiant Damage
+ [[3d8]] on Crit
+ [[1d8]] if Undead or Fiend
+ [[1d8]] on Crit| 3rd Level Spell Slot, • [[4d8]] Radiant Damage
+ [[4d8]] on Crit
 • [[1d8]] if Undead or Fiend
+ [[1d8]] on Crit|4th/5th Level Spell Slot, • [[5d8]] Radiant Damage
+ [[5d8]] on Crit
 • [[1d8]] if Undead or Fiend
+ [[1d8]] on Crit}}}
?{Damage Type|Physical,
/fx glow-blood @{target|TargetA|token_id}|Physical&Divine,
/fx glow-blood @{target|TargetA|token_id}
/fx bomb-holy @{target|TargetA|token_id}}
October 06 (8 years ago)
Tetsuo
Forum Champion
This is possible via html escape entities and query nesting. Heres the link to the wiki that explains it:

https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries
October 06 (8 years ago)
Gotcha. I thought those were only for using the characters in the code without messing with the code.
October 06 (8 years ago)
Tetsuo
Forum Champion
This is used anytime you want to place a set of {} inside a query ?{}. The ?{} ends as soon as it sees a }, so going ?{Which attribute|@{strength}} will cause a problem.
October 06 (8 years ago)

Edited October 06 (8 years ago)

Franky H. said:

This is used anytime you want to place a set of {} inside a query ?{}. The ?{} ends as soon as it sees a }, so going ?{Which attribute|@{strength}} will cause a problem.


That's only partially true, see this line from the wiki.

Due to the order of operations, calls (i.e. @{Attribute}, %{Ability}, #Macro) are parsed to their values before Roll Queries are executed.

So the @{strength} would be converted to the value of that attribute before the query and it would not see the }. It is the nesting of the queries that will cause the first query to see the | and } of the other query and stop.  
October 06 (8 years ago)

Edited October 06 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Actually, Frankie's example will not cause a problem unless the value of strength contains a bar, comma, or end bracket. Due to the order of operations attributes and abilities are resolved before roll queries. When nesting things inside queries, never replace any character that is part of an attribute or ability call; you must replace them in the actual text of the attribute or ability.

https://wiki.roll20.net/Dice_Reference#Order_of_Op...

an example nesting:

?{outer query|
	option 1, ?{option1 query @{exampleattribute}&#124;
option1 query option first&#44;select text&#124;
option1 query option second&#44; second select text or further nesting&#125;| option2, text or nest something else %{orAnAbilityCall} }

If the attribute or ability called contains problem characters, such as an ability containing a roll template, the characters must be replaced to the proper nesting level in those as well. I've only shown a single level of nesting above, but you can nest to 99 levels, and must escape your escapes an additional time for each level; usually by escaping the & with & at each level (which is also how I am getting the entities to not be replaced by the forums).

Any macro being made with html entities should be made as a character ability as the global macros replace the entities when they are reopened, making maintenance difficult.

Hope that helps,

Scott
October 06 (8 years ago)

Edited October 06 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ninja'd by Ed. Won't edit this in so as to not replace the html entities in the post.
October 06 (8 years ago)
Finally!
October 06 (8 years ago)

Edited October 06 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
:-D

Edit: and I suppose I should post what my example looks like without replacements (tabbed for readability):

?{outer query|
	option 1, ?{option1 query @{exampleattribute}|
		option1 query option first,select text|
option1 query option second, second select text or further nesting}
|
option2, text or nest something else %{orAnAbilityCall}
}
Bolded section is where the replacements are in the example above.
October 06 (8 years ago)
Tetsuo
Forum Champion
What they said. It's a steep learning curve. Those of us who think we know what we're talking about are still learning every day. :D thanks Ed and Scott