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

How to switch weapons in a macro using Roll Queries

February 23 (9 years ago)
AliceSteel
Sheet Author
API Scripter
I'm working on upgrading a number of my character's macros and am wanting to have my weapon based abilities ask which weapon I'm using and then use the related attributes throughout the rest of the macro. I've managed to get the drop-down working but I'm having trouble managing to get it to switch the rest of the attributes.

Example ability macro:
?{Weapon|@{weapon1name}, 1|@{weapon2name}, 2}
&{template:default} {{name=Arcane Channeling: Touch of Idiocy}} {{Spell Level=2}} {{Caster Level=@{level} }} {{Action=Standard Action}} {{Target=Creature or object touched}} {{Attack=[[ @{weapon2attackcalc} }  ]] vs AC }} {{On-hit=[[ @{weapon2damage} ]] @{weapon2type} damage}} {{On-hit effect=Target takes a [[1d6]] penalty to it's INT, WIS, and CHA for [[@{level}*10]] minutes}} {{Effect Cont.=Penalty can't reduce stats below 1 but can restrict it's spell usage}} {{Crit Confirmation=[[@{weapon2attackcalc}  ]] vs  AC }} {{On-confirm=[[ @{weapon2crit} ]] @{weapon2type} damage}}
February 23 (9 years ago)
As cool as it would be if we could just do something like @{weapon?{Weapon}attackcalc}, that's unfortunately not possible. (This is due to the fact that Roll Queries only pop up after Attributes are parsed, as per the order of operations.)

Instead, we'll have to nest the entire Roll Template within the Roll Query, i.e. with @{weapon2attackcalc} replaced with @{weapon1attackcalc} for the first dropdown field, etc.

However, and I quote from Advanced Usage for Roll Queries:
Roll Queries currently end at the first closing brace the parser encounters. Within a Roll Query, other characters that serve as Roll Query syntax (vertical bars and commas) will always be treated as such by the parser, potentially causing unwanted behavior when placed within the Roll Query for other purposes.
I see tons of non-Attribute closing braces, and a few commas in the Roll Template, so we'll have to make the HTML replacements, as outlined by Advanced Usage for Roll Queries.
February 23 (9 years ago)
AliceSteel
Sheet Author
API Scripter
So basically it'd just be easier to make a separate set of weapon related macros and switch which ones are on my bar when I switch weapons.

Now if only Roll Queries allowed for the same option label to have different meanings throughout the macro. For example replacing the 1 and 2 in the earlier macro's Roll Query with @{weapon1attackcalc} and @{weapon2attackcalc} in an otherwise identical set there but having it only ask for the choice once.
February 23 (9 years ago)

Edited February 23 (9 years ago)
Indeed; that would be another super-convenient thing to have. But, we make do:
&{template:default} {{name=Arcane Channeling: Touch of Idiocy}} {{Spell Level=2}} {{Caster Level=@{level}}} {{Action=Standard Action}} {{Target=Creature or object touched}} ?{Weapon|

@{weapon1name}, {{Attack=[[ @{weapon1attackcalc} ]] vs AC}} {{On-hit=[[ @{weapon1damage} ]] @{weapon1type} damage}} {{Crit Confirmation=[[ @{weapon1attackcalc} ]] vs AC}} {{On-confirm=[[ @{weapon1crit} ]] @{weapon1type} damage}} |

@{weapon2name}, {{Attack=[[ @{weapon2attackcalc} ]] vs AC}} {{On-hit=[[ @{weapon2damage} ]] @{weapon2type} damage}} {{Crit Confirmation=[[ @{weapon2attackcalc} ]] vs AC}} {{On-confirm=[[ @{weapon2crit} ]] @{weapon2type} damage}}

} {{On-hit effect=Target takes a [[ 1d6 ]] penalty to it's INT, WIS, and CHA for [[ @{level}*10 ]] minutes}} {{Effect Cont.=Penalty can't reduce stats below 1 but can restrict it's spell usage}}
February 23 (9 years ago)
AliceSteel
Sheet Author
API Scripter
Any idea why this isn't giving me a proper dropdown?

/em intones draconic words of power as he prepares to strike his foe
?{Spell | %{Cobalt|ACShockingGrasp} | %{Cobalt|ACTouchOfIdiocy} | %{Cobalt|ACDimensionHop} }
Tried it with userfriendly names and without the character name being in the ability calls as well. With the userfriendly names it gave a Type Error message and without the character name it gave the same textbox result. Oh, also tried without most of the spaces with the same sort of result.

Though I suppose it might just be a side effect of whatever's making all the default templated abilities that SHOULD be perfectly functional not appear at all and all the tests from earlier show up as just a small bar with a hint of the color the name field is supposed to be... Wonder if the DM broke something while he was playing around with premade scripts from the wiki's index earlier...
February 23 (9 years ago)

Edited February 23 (9 years ago)
What do you mean by "userfriendly names"?

Anyhow, the Troubleshooting section of Advanced Usage for Roll Queries directly addresses the issue you're having.
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
Let me know if something's unclear.

Also, here's one example of the process required to nest Abilities (consisting of Roll Templates) within Roll Queries, in case you're interested.
February 23 (9 years ago)
AliceSteel
Sheet Author
API Scripter
For ACShockingGrasp I had used "Shocking Grasp (SL1)"

Also, WOW, Roll Queries are a LOT less useful than I thought they were. You have to completely rewrite any abilities you want them to cal to the point that you can't use them directly anymore... I wonder if there's a script to enable such multi-ability selectors without needing to rewrite all the abilities involved...
February 23 (9 years ago)
If you'd like to use the Abilities both individually and collectively (through one macro), a popular alternative is using Command Buttons to create a menu of sorts:
&{template:default} {{name=Spells}} {{ [Shocking Grasp](~ACShockingGrasp)
[Touch of Idiocy](~ACTouchOfIdiocy)
[Dimension Hop](~ACDimensionHop) }}