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

Conditional statements inside templates inside drop down list queries

July 15 (7 years ago)

Edited July 15 (7 years ago)

So after spending probably around 6 or 7 hours working out a damage modifier system that uses the "size" attribute of a character to amplify or reduce the amount of damage dealt, I decided to stick it in my damage macros, and suddenly everything breaks.

?{Weapon Type|
H1: @{selected|msH1}, &{template:default} {{name=Weapon Attack }} {{@{selected|character_name} dealt [[ (2d5) * ( {{(@{selected|Size}-@{target|Size}) ,-1}>0}*(1) + (abs(0.@{selected|Size}-0.@{target|size})*2.5) )]] damage. }} |
H2: , Rest removed while testing
}

Naturally the actual code isn't all 1 macro like this. Normally there's the weapon select macro which is just the drop down list that allows you to select what weapon to use.
Selecting the weapon will run a macro that setsup the template and calls the damage ability for that weapon's character sheet to get the damage.

Inside the damage macro I had added this part:

 * ( {{(@{selected|Size}-@{target|Size}) ,-1}>0}*(1) + (abs(0.@{selected|Size}-0.@{target|size})*2.5) )"

From what I can tell the problem seems to come from the use of the conditional statement as if I remove it, it will suddenly work.
The reason there is the HTML for } between "-1", ">" and "*(1)" is because using the normal } causes the query bug where it just turns the drop down list into text as it believes it is meant to end early, and I imagine the reason the template breaks is due to similar situation, it somehow reading the 2 html }s as the close for the template for some reason.

Either way, doubtful i'll anyone will be able to fix it, but attempts will be appreciated.

Alternatively if anyone else happens to have a suggestion on how to increase/decrease damage by a percentage based off of the unit sizaes feel free to say.

July 15 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

This is due to the fact that roll queries do not work with characters involved in their syntax included in their options or option values. See the wiki on advanced roll templates for the basic run down. I also just posted a Google sheet to help with drop-down nesting in Keith's stupid tricks thread.

Thanks, using your google sheet fixed it. Thought I had replaced all the values I needed to, but I guess I missed something.
July 15 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Yep, it's easy to do, or to not encode enough/too much