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

[PF] Pathfinder Sheet Dropdown Attack Query

I'm trying to make a macro for my weapon attacks from the Pathfinder sheet, so I can use a dropdown query to collapse all of my weapon attacks and slim down my macro bar.

However, I don't quite know how to do it. I tried dragging my roll query unto the macro bar, but I can't rename it or inspect it.

What do I do?
March 14 (9 years ago)

Edited March 14 (9 years ago)
chris b.
Pro
Sheet Author
API Scripter
You want to use the nesting roll query concept to escape characters of calls/macros inside of others:

https://wiki.roll20.net/Macros#Example_.28nesting_...

each attack can be written as (for the selected token):
%{selected|repeating_weapon_$X_attack-roll}  
where X is the row starting with 0. (generally should be the same as the # that appears next to the expand/collapse arrow)  And you'll have to know how many weapons beforehand, there is no way to dynamically determine that without using the API and writing javascript.

then you nest a bunch of those inside the ? query by escaping the special characters with their html code equivalents.

So this SHOULD work for the first 2 items: (i have not tested this but basically i just substituted the above in for ?{attack with|1,attk1|2,attk2} 

(remove the spaces between & and #, had to put those in for the forums here )
?{attack with|1,& #37;& #123;selected& #124;repeating_weapon_$1_attack-roll& #125;|2,& #37;& #123;selected& #124;repeating_weapon_$2_attack-roll& #125;}
or if you want to use the name of the attack in the dropdown:

?{attack with|& #64;{selected& #124;repeating_weapon_$1_name& #125;,& #37;& #123;selected& #124;repeating_weapon_$1_attack-roll& #125;|& #64;&# 123;selected& #124;repeating_weapon_$2_name& #125;,& #37;& #123;selected& #124;repeating_weapon_$2_attack-roll& #125;}
Ah, that is fantastic, thank you!
March 14 (9 years ago)
chris b.
Pro
Sheet Author
API Scripter
i had to re-edit it to fix the code so copy it again, i had to add spaces between & and # or the forum was actually putting the html in not the codes
March 14 (9 years ago)
chris b.
Pro
Sheet Author
API Scripter
well actually that didn't work.. i think you cannot call the % rolls from within a query

there are some discussions on this
https://app.roll20.net/forum/post/3002531/slug%7D

https://app.roll20.net/forum/post/2154264/slug%7D

https://app.roll20.net/forum/post/2722784/slug%7D




I'm afraid that goes over my head completely...

Can I do it with @ to get the attributes? It's important, since I work with a lot of buffs (alchemist character; mutagens, enlarge person, etc), that I incorporate variables rather than constants.
March 14 (9 years ago)

Edited March 14 (9 years ago)

chris b. said:

well actually that didn't work.. i think you cannot call the % rolls from within a query

Check out Advanced Usage for Roll Queries; you'll see that Ability calls (e.g. %{Selected|Attack1}) are not problematic to Roll Queries per se. What is often problematic are the values of the Abilities. (Calls and values explained.)

This case is directly addressed in Roll Query Troubleshooting:

Roll Query Troubleshooting

Locate and replace all problematic characters within the values of any Attributes, Abilities or Macros.
Since those values now contain HTML entities, they are probably unable be able to be called individually (i.e. outside of a Roll Query). So, you might now consider directly inserting these values into your Roll Query, replacing their call.
Note that macros which contain HTML entities may no longer function autonomously and must be saved as Abilities.
To reiterate an important point: do not subject any @{Attribute}, %{Ability} or #Macro calls to any character replacements.
March 15 (9 years ago)

Edited March 15 (9 years ago)
vÍnce
Pro
Sheet Author

Silvyre said:

chris b. said:

well actually that didn't work.. i think you cannot call the % rolls from within a query

Check out Advanced Usage for Roll Queries; you'll see that Ability calls (e.g. %{Selected|Attack1}) are not problematic to Roll Queries per se. What is often problematic are the values of the Abilities. (Calls and values explained.)

I banged my head way too long when trying to workout a query with %macro names and I gave up... ;-(  

I'm assuming the query tries to resolve the macro, but the macro itself contains special characters which causes the query to fail.
example:
?{Choose Attack.|Attack1,%{selected|repeating_weapon_$0_attack-roll}|Attack2,%{selected|repeating_weapon_$1_attack-roll}}
The query fails at the inital propmt;
Attack1, &{template:pf_attack
It looks like it got as far as the first " } " included within the attack macro and died thinking it was the end of the query...

Curious, even if we replaced all the problematic special characters in the attack macro, would the query resolve both attacks and only give the result of the one chosen?  Seems like using % macro names inside a query, while theoretically possible, isn't practical. ;-(
March 15 (9 years ago)

Edited March 15 (9 years ago)

Vince said:

It looks like it got as far as the first " } " included within the attack macro and died thinking it was the end of the query...

Yup. This behaviour is also outlined in the first sentences of Advanced Usage for Roll Queries.

Curious, even if we replaced all the problematic special characters in the attack macro, would the query resolve both attacks and only give the result of the one chosen?

I'm not sure what you mean by this...

Seems like using % macro names inside a query, while theoretically possible, isn't practical. ;-(

Agreed, but some might prefer, for whatever reason, to nest Ability calls within Roll Queries. MrBritishGamer learned how to do so within this thread.

I'm assuming the query tries to resolve the macro, but the macro itself contains special characters which causes the query to fail.
example:
?{Choose Attack.|Attack1,%{selected|repeating_weapon_$0_attack-roll}|Attack2,%{selected|repeating_weapon_$1_attack-roll}}
The query fails at the inital propmt;
Attack1, &{template:pf_attack
It looks like it got as far as the first " } " included within the attack macro and died thinking it was the end of the query...

Yes; true. That first closing curly brace is problematic and needs to be replaced with its HTML entity, as per Roll Query Troubleshooting.

However, you're dealing with sheet buttons (as opposed to conventional Abilities on the Attributes & Abilities tab), and there's normally no way to edit the values of those sheet buttons (i.e. make character replacements on the contents of those sheet buttons) short of editing the sheet's HTML.

Fortunately, the Pathfinder Character Sheet provides a "Macro Text" section in this instance. Treat the "Macro Text" as the value of the of the Ability call linked to the sheet button, and work through the procedures outlined in Advanced Usage for Roll Queries and Roll Query Troubleshooting. This should allow you to get the ?{Choose Attack.} Query working.

Please let me know if you have any questions.
March 15 (9 years ago)

Edited March 15 (9 years ago)
vÍnce
Pro
Sheet Author

Silvyre said:

Vince said:  Curious, even if we replaced all the problematic special characters in the attack macro, would the query resolve both attacks and only give the result of the one chosen?


I'm not sure what you mean by this...

Fortunately, the Pathfinder Character Sheet provides a "Macro Text" section in this instance. Treat the "Macro Text" as the value of the of the Ability call linked to the sheet button, and work through the procedures outlined in Advanced Usage for Roll Queries and Roll Query Troubleshooting. This should allow you to get the ?{Choose Attack.} Query working.

Please let me know if you have any questions.
Your last paragraph is what I was referring to, however I meant editing the actual macro-text and still use the attack %macro's name.  It sounds like you are saying to forgo using the %macro's name all together and instead insert the macro-text (with special character treatments) into the query, correct?  
Thanks Silvyre
March 15 (9 years ago)

Edited March 15 (9 years ago)

Vince said:

It sounds like you are saying to forgo using the %macro's name all together and instead insert the macro-text (with special character treatments) into the query, correct? 

It's what I [highly] suggest doing, but it's usually not "strictly necessary". In this case, "strictly necessary" hinges on the presence of the "Macro Text" field within your repeating attack sections. If your repeating sections did not provide a way to edit the outputs of its corresponding sheet buttons, it would be "strictly necessary" to replace the calls with values.

In this case, if you chose to make the replacements to the Macro Text (e.g. of the first repeating section), you would be able to call it from within a Roll Query (e.g. ?{Attack|Scimitar, %{selected|repeating_weapon_$0_attack-roll}|...}). However, you would no longer be able to call it from outside of such a Roll Query (e.g. by using the sheet button; the Macro Text is now otherwise "broken").
I... have no idea what all of that means. :< What does "insert the macro-text (with special character treatments)" mean? Sounds like technobabble to me.
March 16 (9 years ago)

Please let me know if there is any other terminology I can help clarify. :)
March 17 (9 years ago)

Edited March 17 (9 years ago)
vÍnce
Pro
Sheet Author
In this particular case, you cannot use 
?{Choose Attack.|Attack1,%{selected|repeating_weapon_$0_attack-roll}|Attack2,%{selected|repeating_weapon_$1_attack-roll}}
because those macros actually call a MUCH larger and more complicated macro as found in the macro-text field/attribute under a specific attack on the sheet.  The special characters found within the macro-text will cause the query to fail unless those special characters are replaced. 
So, in order to make a multi-attack query for the PF sheet;
  1. You need to take the macro found in the attacks macro-text field on the sheet copy/paste into a text editor.  Edit each attribute found in the macro to include it's repeating section name or id.  ie @{total-attack} would be changed to @{selected|repeating_attacks_$0_total-attack} or change $0 to the repeating row's id.  Warning: this will result in a HUGE macro.
  2. Create your query and substitute your edited macro-text from above for each of your query's values (however many attacks you want to choose from...)
  3. Now you need to account for any special characters found in your query and substitute.  Silvyre has included all the info needed for this.
I would try getting one attack working before adding more.  ;-)
March 17 (9 years ago)
Sounds great, Vince! Once you get it down, the advanced Roll Query is a very powerful tool to have in one's macro-maker's toolbox.

Some users opt for an "Ability Command Button menu" in place of huge Roll Queries, so I'll post an example of one up just in case:
&{template:default} {{name=Weapons}} {{ 
[@{repeating_weapon_$0_name}](~repeating_weapon_$0_attack-roll)
[@{repeating_weapon_$1_name}](~repeating_weapon_$1_attack-roll)
etc. 
}}
March 17 (9 years ago)
vÍnce
Pro
Sheet Author

Silvyre said:

Sounds great, Vince! Once you get it down, the advanced Roll Query is a very powerful tool to have in one's macro-maker's toolbox.

Some users opt for an "Ability Command Button menu" in place of huge Roll Queries, so I'll post an example of one up just in case:
&{template:default} {{name=Weapons}} {{ 
[@{repeating_weapon_$0_name}](~repeating_weapon_$0_attack-roll)
[@{repeating_weapon_$1_name}](~repeating_weapon_$1_attack-roll)
etc. 
}}
I think that would be a great alternative!

March 18 (9 years ago)

Edited March 18 (9 years ago)
chris b.
Pro
Sheet Author
API Scripter
ok.. I think I figured out what you are saying ... so if we want to make this sort of query available for players, and we want them to still use rollbuttons, we need to construct a SECOND macro-text-escaped which replaces the %@{},| etc with &#xx; (which will repopulate when the user makes a change to macro-text) and then copy this SECOND macro-text into the rollquery.*

That would be for an ability command button interface in a roll template.

Then, if we want to use it in a roll query, we also have to escape the second macro-text it a second time? specifically by replacing all the & with & ?






* I considered at one point replacing all the values in the macro-text when they change, since I have code that does that already, but I figured players don't need even more attributes taking up memory.
March 18 (9 years ago)

Edited March 18 (9 years ago)
You don't need to escape any [additional] characters within the value of an Ability in order to call it from an Ability Command Button (only from an API Command Button).

Don't escape Attribute/Ability calls in order to nest them within a Roll Query; Advanced Usage for Roll Queries and Roll Query Troubleshooting explains why.

Check out this post for more insight into what requires escaping.
April 20 (9 years ago)

Edited April 20 (9 years ago)
Sorry about necroing an old thread but I've been bashing my head against this exact problem for a few weeks and figured I'd post my solution.

@{Fane|PC-whisper} &{template:pf_generic} {{character_name=@{Fane|character_name}}} {{character_id=@{Fane|character_id}}} {{subtitle}} {{Name=
?{Attack with?|Bastard sword, @{Fane|repeating_weapon_$0_name}}}{{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$0_crit-target} ]] + [[ @{Fane|repeating_weapon_$0_total-attack} ]] ]]}}} {{damage=[[ @{Fane|repeating_weapon_$0_damage-dice-num}d@{Fane|repeating_weapon_$0_damage-die} + [[ @{Fane|repeating_weapon_$0_total-damage} ]] ]]}}}|Spiked shield, @{Fane|repeating_weapon_$1_name}}}} {{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$1_crit-target} ]] + [[ @{Fane|repeating_weapon_$1_total-attack} ]] ]]}}} {{damage=[[ @{Fane|repeating_weapon_$1_damage-dice-num}d@{Fane|repeating_weapon_$1_damage-die} + [[ @{Fane|repeating_weapon_$1_total-damage} ]] ]]}}}|Bastard Sword 2H, @{Fane|repeating_weapon_$2_name}}}} {{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$2_crit-target} ]] + [[ @{Fane|repeating_weapon_$2_total-attack} ]] ]]}}} {{damage=[[ @{Fane|repeating_weapon_$2_damage-dice-num}d@{Fane|repeating_weapon_$2_damage-die} + [[ @{Fane|repeating_weapon_$2_total-damage} ]] ]]}}|Bastard sword PA, @{Fane|repeating_weapon_$3_name}}}}{{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$3_crit-target} ]] + [[ @{Fane|repeating_weapon_$3_total-attack} ]] ]]}}}{{damage=[[ @{Fane|repeating_weapon_$3_damage-dice-num}d@{Fane|repeating_weapon_$3_damage-die} + [[ @{Fane|repeating_weapon_$3_total-damage} ]] ]]}}}|Bastard sword 2h PA, @{Fane|repeating_weapon_$4_name}}}} {{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$4_crit-target} ]] + [[ @{Fane|repeating_weapon_$4_total-attack} ]] ]]}}} {{damage=[[ @{Fane|repeating_weapon_$4_damage-dice-num}d@{Fane|repeating_weapon_$4_damage-die} + [[ @{Fane|repeating_weapon_$4_total-damage} ]] ]]}}}|Combat manuver, A combat manuver}}} {{Attack=[[ 1d20+ @{Fane|Cmb}]]}}} |TWF, Both weapons}}} {{@{fane|repeating_weapon_$5_name}=[[ 1d20cs>[[ @{Fane|repeating_weapon_$5_crit-target} ]] + [[ @{Fane|repeating_weapon_$5_total-attack} ]] ]]}}} {{slash damage=[[ @{Fane|repeating_weapon_$5_damage-dice-num}d@{Fane|repeating_weapon_$5_damage-die} + [[ @{Fane|repeating_weapon_$5_total-damage} ]] ]]}}} {{@{fane|repeating_weapon_$6_name}=[[ 1d20cs>[[ @{Fane|repeating_weapon_$6_crit-target} ]] + [[ @{Fane|repeating_weapon_$6_total-attack} ]] ]]}}} {{bash damage=[[ @{Fane|repeating_weapon_$6_damage-dice-num}d@{Fane|repeating_weapon_$6_damage-die} + [[ @{Fane|repeating_weapon_$6_total-damage} ]] ]]}}} |TWF power attack, TWF power attack}}} {{@{fane|repeating_weapon_$7_name}=[[ 1d20cs>[[ @{Fane|repeating_weapon_$7_crit-target} ]] + [[ @{Fane|repeating_weapon_$7_total-attack} ]] ]]}}}{{Slash Damage=[[ @{Fane|repeating_weapon_$7_damage-dice-num}d@{Fane|repeating_weapon_$7_damage-die} + [[ @{Fane|repeating_weapon_$7_total-damage} ]] ]]}}}{{@{fane|repeating_weapon_$8_name}=[[ 1d20cs>[[ @{Fane|repeating_weapon_$8_crit-target} ]] + [[ @{Fane|repeating_weapon_$8_total-attack} ]] ]]}}} {{Bash damage=[[ @{Fane|repeating_weapon_$8_damage-dice-num}d@{Fane|repeating_weapon_$8_damage-die} + [[ @{Fane|repeating_weapon_$8_total-damage} ]] ]]}}}|Throwing axe, @{Fane|repeating_weapon_$9_name}}}} {{Attack=[[ 1d20cs>[[ @{Fane|repeating_weapon_$9_crit-target} ]] + [[ @{Fane|repeating_weapon_$9_total-attack} ]] ]]}}} {{damage=[[ @{Fane|repeating_weapon_$9_damage-dice-num}d@{Fane|repeating_weapon_$9_damage-die} + [[ @{Fane|repeating_weapon_$9_total-damage} ]] ]]}}}} }}}


Does all the math for you off your sheet and displays it in a template. Of course you're gonna have to replace Fane with your character name or Selected.
Sorry about the necro, but by converting the problematic characters into HTML you do break the Sheet Roll button, but allow use inside queries. I, personally, am fine with breaking the Sheet Roll button in favor of allowing a single token action that gives access to all weapons. The only thing that I know of right now (for me anyways) is the you won't be able to get that query to work with the Power Cards API. I found it to be quite easy once I was able to wrap my head around how queries work.