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

Trying to figure out how to call Abilities in Macro Querys

1591684788

Edited 1591685448
So, I'm working on my own game system. It's a bit of a blend between Savage Worlds and Call of Cthulu. I'm not good at HTML/CSS to design a custom character sheet that way, and I haven't been able to find anyone whom I can pay to do it within my budget. So I've been using the Attributes and Abilities functions to basically plug in all of the stuff needed. Here's where my problem arises: Each Practice (skill) has within it three specialties. Practices are represented by a die size, and specialties by a flat number. I've got both the Practices and the specialties set up in the Attributes section. For example, one such Practice is "Fitness". It has three specialties, Track, Swimming, and Climbing. I made an Ability that is used for the Fitness roll, and also calls for them to select which Specialty they'll be using.This will be used for every character, and calls upon that Character's attribute. Fitness: [[d@{Fitness}]]+?{Specialty? |Track, @{Track} (Track) |Swimming, @{Swimming} (Swimming) |Climbing, @{Climbing} (Climbing)} When rolled, (and for the example, they use Track for the specialty) it reads "Fitness: [Fitness dice roll] + [Track bonus] (Track)" Now, certain Practices are reserved for Combat. These are Hand-To-Hand, Marksman, and Lore(Spellcrafting). Lore is unique in that the Specialty is the subject they are familiar in and it doesn't provide a bonus. Instead, spells have different defenses that they target, so the player selects one from those. I'm trying to create two Abilities/Macros that utilize a query to decide which Ability they should roll, so that my players aren't bogged down to hell with macros in their bar. The Macro I made for Attack is this: ?{Attack type?|Hand-To-Hand, %{Selected|Hand-To-Hand}|Marksman, {Selected|%Marksman}|Spellcraft, {Selected|%Lore(Spellcraft)}} My hope was that it would give them their choice of what sort of attack they are making (Hand-To-Hand) (Marksman) (Spellcraft), and then they'll go through the Ability as normal. For some reason, however, the output is like this: "Attack type?": Hand-To-Hand Skirmishing Brawling Wrestling (Note that Skirmishing, Brawling, and Wrestling are the Specialties for Hand-To-Hand) Whenever I select any of the options, it outputs another drop down: "Specialties?": Marksman %Marksman Selecting one of those gives me this output in the chat Hand-To-Hand: [Hand-To-Hand Dice roll] + {Selected|Spellcraft, {Selected|%Lore(Spellcraft)}} From what I can tell, it's activating the first ability, then blending the options from the Macro's query to the Ability's query. For reference here are the Ability macros for Hand-To-Hand, Marksman, and Lore(Spellcraft). Hand-To-Hand: [[d@{Hand-To-Hand}]]+?{Specialty? |Skirmishing, @{Skirmishing} (Skirmishing) |Brawling, @{Brawling} (Brawling) |Wrestling, @{Wrestling} (Wrestling)} Marksman: [[d@{Marksman}]]+?{Specialty? |Archery, @{Archery} (Archery) |Firearms, @{Firearms} (Firearms) |Thrown, @{Thrown} (Thrown)} Lore (Spellcraft): [[d@{Lore(Spellcraft)}]] vs ?{Target?|Physical|Reflexive|Mental|Difficulty} I could use any help able to be offered by this, and if you have any further suggestions, I'd be happy to hear them. Thanks a bunch. (P.S. Also looking for play testers if anyone is interested.)
1591686590
GiGs
Pro
Sheet Author
API Scripter
This is the classic nested query problem - probably the single most common question that gets asked on the forum. The problem is two-fold: First, when you tricher a Macro, roll20 reads all the mentioned abilities in the macro, retrieves their text, and places them in the macro. Then it performs the macro. So when you run this: ?{Attack type?|Hand-To-Hand, %{Selected|Hand-To-Hand}|Marksman, {Selected|%Marksman}|Spellcraft, {Selected|%Lore(Spellcraft)}} Roll20 grabs th abilities mentioned, and places them in the macro, turning it into this ?{Attack type?| Hand-To-Hand, Hand-To-Hand: [[d@{Hand-To-Hand}]]+?{Specialty?| &nbsp;&nbsp;&nbsp;&nbsp;Skirmishing, @{Skirmishing} (Skirmishing)|Brawling, @{Brawling} (Brawling)|Wrestling, @{Wrestling} (Wrestling)}| Marksman, Marksman: [[d@{Marksman}]]+?{Specialty?| &nbsp;&nbsp;&nbsp;&nbsp;Archery, @{Archery} (Archery)|Firearms, @{Firearms} (Firearms)|Thrown, @{Thrown} (Thrown)}| Spellcraft, Lore (Spellcraft): [[d@{Lore(Spellcraft)}]] vs ?{Target?|Physical|Reflexive|Mental|Difficulty}} I've inserted a couple of linebreaks to make it more readable. The second problem is: roll20 doesnt understand nested queries. But thats what you have here - queries inside queries. When you run the Attack Type query, it thinks every | after it is a new row, and every } after it ends the query.&nbsp; So the query will end just after wrestling.&nbsp; The way to handle this is pretty complex: you need to replace certain characters in the nested queries (any | , and } ) with html entities as described on this page:&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> Since this specific query isnt that complex, I'll have a go at doing it for you: ?{Attack type?| Hand-To-Hand, Hand-To-Hand: [[d@{Hand-To-Hand}]]+?{Specialty? &amp;#124; &nbsp;&nbsp;&nbsp;&nbsp;Skirmishing&amp;#44;@{Skirmishing} (Skirmishing) &amp;#124; Brawling&amp;#44; @{Brawling} (Brawling) &amp;#124; Wrestling&amp;#44; @{Wrestling} (Wrestling)&amp;#125;| Marksman, Marksman: [[d@{Marksman}]]+?{Specialty?&amp;#124; &nbsp;&nbsp;&nbsp;&nbsp;Archery&amp;#44; @{Archery} (Archery)&amp;#124;Firearms&amp;#44; @{Firearms} (Firearms)&amp;#124;Thrown&amp;#44; @{Thrown} (Thrown)&amp;#125;| Spellcraft, Lore (Spellcraft): [[d@{Lore(Spellcraft)}]] vs ?{Target?&amp;#124;Physical&amp;#124;Reflexive&amp;#124;Mental&amp;#124;Difficulty&amp;#125;} You can see how fiddly and uggly this gets - it's possible I may have missed onesomething&nbsp; One thing to notice is - you have to incorporate the nested queries in the macro, and modify them.&nbsp; Since the coding for this kind of things gets complicated, let me point you towards Chat Menus as a superior alternative:&nbsp; <a href="https://app.roll20.net/forum/permalink/5927072/" rel="nofollow">https://app.roll20.net/forum/permalink/5927072/</a> Ad as youre a Pro user, if those abilities are buttons on a character sheet, there are two scripts which you can use to automatically build menus to use for them. My Universal Chat Menus , and Scott's Menu Maker . Save yourself some headaches and spend a little time setting one of those up.
Thank you so much :) I'd looked on the forums a bit, and I'd seen the stuff about Nesting Queries. I wasn't sure where to place the HTML replacements, so your example helps a lot. I haven't seen anything about the Chat Menus, but I'll take a look and see what I can implement. Thanks again for all your help.
1591724133
GiGs
Pro
Sheet Author
API Scripter
You're welcome :) The big advantage of chat menus is you dont need to modify the original macros, they work fine. The Chat menu equivalent of the macro above is, I think &amp;{template:default} {{name=My Chat menu}} {{[Hand-To-Hand](~Selected|Hand-To-Hand) [Marksman](~Selected|Marksman) [Spellcraft](~Selected|Lore (Spellcraft&amp;#41;) }} Note that Lore (Spellcraft) needs a html entity to replace the ). i strongly recommend not using brackets in ability names for this reason. (Along with most other non-alphanumeric characters.) Anyway, you can whisper the chat menu so it doesnt clutter chat for everyone, and it just prints a button for each Ability.&nbsp; Just for the record, while writing this I noticed you had two of the % in the wrong place in the original macro: ?{Attack type?|Hand-To-Hand, %{Selected|Hand-To-Hand}|Marksman, {Selected|%Marksman}|Spellcraft, {Selected|%Lore(Spellcraft)}} Marksman and spellcraft wouldn't work even if you didnt have a nested query issue.&nbsp;