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

Variable from query

Want to see if there is a way to do what I want. I'm making a macro for a spell, I want it to work with the 5e spell tracking, so I want to query the user for the spell level. However, the spell's level will also determine how much damage the spell does. Is there a way to query for the spell level and have the result of that query affect the damage? Currently, I have a separate macro for each spell level, which isn't terrible but also not ideal.
April 24 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Depends on how the damage is affected. If it is 1d8/level or something, then you could just do [[?{spelllevel}d8]]
April 24 (8 years ago)

Edited April 24 (8 years ago)
I can't do that as I wanted to use a roll template, and the spell level and damage are in two separate blocks i.e. {{dmg1=[[2d4]]}} {{spelllevel=1}}

To rephrase my question, I wanted to query for a value and use that value in two separate places without repeating the query. After some digging, I found that what I wanted to do is not possible, at least not the way I wanted to do it. I kind of suspected as much.

The obvious workaround that I missed at first is to basically wrap the full macro for each spell level in a query, like ?{Spell Level| 1, #spell-lvl-1 | 2, #spell-lvl-2 }. Doesn't save any typing and I did have to do some character replacement, but it does work and it's only one button on the macro bar.
April 24 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Doesn't matter that the fields are two separate fields, you can reuse roll queries in the same message, which a roll template is. So, taking your example, let's say that the spell does 2d4 at 1st level + 1d4 for every level beyond 1st, that would be:
{{dmg1=[[ [[1+?{Spell Level}]]d4]]}} {{spelllevel=?{Spell Level}}}
April 24 (8 years ago)
I created a generic character journal that I named spells and I created many spells through abilities on sheet (also created three attributes for spell casting one is jb_spell_mod for spellcaster modifier, jb_pb is for proficiency die (I am using that option from DMG, but could place bonus their too) and last is jb_level (this last one affects damage for cantrips);  I set this up in campaign without a character sheet and uses basic Roll20 template, so can be used in any 5e game no matter which character sheet may be in use

Here is example for Burning Hands

/desc &{template:default} {{name=Burning Hands Spell}} {{School=1st-level evocation}} {{Casting Time=action}} {{Range=Self (15 ft cone)}} {{Components=V,S}} {{Duration=Instant}} {{Slot Level=[[?{Level|1}]]}} {{Saving Throw=DC [[8 + @{jb_spell_mod} + @{jb_pb} ]] DEX}} {{Success=half}} {{Damage=[[?{Level|1}d6+2d6]] fire}}
April 24 (8 years ago)

Edited April 24 (8 years ago)
Well I completely glossed over that when I was reading through the documentation. Good to know though, thanks for quick response!