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

Use query variable multiple times in template

1597332141

Edited 1597332976
There were a lot of great Magic Missile macros around, and I cobbled a few of them together to make this one for my wizard using the 5e OGL Spell Template: @{Thaladar|wtype}&{template:spell} {{level=evocation 1}}  {{name=Magic Missile}} {{castingtime=1 action}} {{range=120 feet}} {{target=One or more creatures within range}} {{v=1}} 0 {{m=0}} {{duration=Instantaneous}} {{description=You create three glowing darts of magical force. Each dart hits a creature of your choice that you can see within range. A dart deals 1d4 + 1 force damage to its target. The darts all strike simultaneously, and you can direct them to hit one creature or several. }} {{athigherlevels=When you cast this spell using a spell slot of 2nd level or higher, the spell creates one more dart for each slot level above 1st. Damage: ?{Cast at what level?|1, [[1d4+1]] + [[1d4+1]] + [[1d4+1]]|2, [[1d4+1]] + [[1d4+1]] + [[1d4+1]] + [[1d4+1]]} }}  @{Thaladar|charname_output} My question is whether there is a way to reference the Cast at what level query result in multiple places in the macro?  For example in the spell level text, it lists evocation 1 as text.  Is there a way to use the query variable so that is shows evocation # (where # is the user-selected value of 1 or 2)?  And more complicated would there be a way to make the number of missiles in the description dynamic to reflect the higher level cast automatically? Meaning if 1 is selected, the description says "You create three glowing darts" and if 2 is selected, it says "You create four glowing darts".  Then I could remove the athigherlevels text as it wouldn't be needed and just list the damage below. EDIT: To provide an example of what I'm looking for, here is a modified version but uses THREE different queries to set the output correctly.  But I have to select the Level 3 times (and choose the same one every time).  I'm hoping to only query once and have the output reflect the selection. @{Thaladar|wtype}&{template:spell} {{level=evocation ?{Spell level?|1,1|2,2 (higher level cast)}}}  {{name=Magic Missile}} {{castingtime=1 action}} {{range=120 feet}} {{target=One or more creatures within range}} {{v=1}} 0 {{m=0}} {{duration=Instantaneous}} {{description=You create ?{What level?|1,three|2,four} glowing darts of magical force. Each dart hits a creature of your choice that you can see within range. A dart deals 1d4 + 1 force damage to its target. The darts all strike simultaneously, and you can direct them to hit one creature or several. Damage: ?{Cast at what level?|1, [[1d4+1]] + [[1d4+1]] + [[1d4+1]]|2, [[1d4+1]] + [[1d4+1]] + [[1d4+1]] + [[1d4+1]]} }}  @{Thaladar|charname_output}
1597332947
The Aaron
Roll20 Production Team
API Scripter
Anywhere you repeat the query label after the initial time will use the same value: [[ (?{Cast at what level?|1|2|3|4|5|6|7|8|9}+2)d4+(?{Cast at what level?}) ]]
The Aaron said: Anywhere you repeat the query label after the initial time will use the same value: [[ (?{Cast at what level?|1|2|3|4|5|6|7|8|9}+2)d4+(?{Cast at what level?}) ]] Got it.  Thanks for this.  I believe I have it now, with the initial Cast at what level? used for the Spell Level text and calculate the number of darts.  The damage is a single number and difficult to see individual dart damage values by mousing over.  I'll have to give more thought on whether it would be possible to output the damage for each dart separately.  But thanks, I'm a little closer now. Here is what I have for now.  @{Thaladar|wtype}&{template:spell} {{level=evocation ?{Cast at what level?|1,1|2,2}}}  {{name=Magic Missile}} {{castingtime=1 action}} {{range=120 feet}} {{target=One or more creatures within range}} {{v=1}} 0 {{m=0}} {{duration=Instantaneous}} {{description=You create [[2+?{Cast at what level?}]] glowing darts of magical force. Each dart hits a creature of your choice that you can see within range. A dart deals 1d4 + 1 force damage to its target. The darts all strike simultaneously, and you can direct them to hit one creature or several. Damage: [[ (?{Cast at what level?|1|2|3|4|5|6|7|8|9}+2)d4+(?{Cast at what level?}+2) ]] }}  @{Thaladar|charname_output}
1597334244
The Aaron
Roll20 Production Team
API Scripter
Rules as written, 5e Magic Missile has all the darts doing the same damage .  I just wrote the above as a convenient example.