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

Evaluating empty fields

1585890397

Edited 1585890619
I'm setting something up in a character sheet to print out a summary of a character power. The idea is to have a one-click button which puts all of the information about a power into the chat. It's working great, except for one thing: Powers that make attacks have an attack bonus, but in many cases, this is autocalculated. Powers that don't make attacks don't have an attack bonus at all (the field is empty). This means that: If I pass {{AttackBonus=@{attack_bonus}}} to the roll template, it handles an empty attack bonus nicely, but the roll template prints out some nasty values, e.g. "@{str_mod}", when I would want it to print the actual value of @{str_mod}. If I pass {{AttackBonus=[[@{attack_bonus}]]}}, it fails in the opposite case: it prints the attack bonus nicely, but generates an error if the attack bonus field is empty. Is there a way to get around this? What I'm aiming for is something that lets me pass {{AttackBonus=[[@{attack_bonus}]]}} but doesn't fail if attack_bonus is an empty attribute. Edit: Or, alternately, lets me pass {{AttackBonus=@{attack_bonus}}}, but have the roll template try to evaluate it if it's non-empty.
1585891299
Kraynic
Pro
Sheet Author
Instead of being empty, you could have value="0" in the line for whatever input is causing your macro to fail.  That would give it the default value of 0, but it can be overwritten manually or by a sheetworker and will retain the later value.
1585891608
vÍnce
Pro
Sheet Author
What happens if you try {{AttackBonus=[[0d0+@{attack_bonus}]]}}
Vince said: What happens if you try {{AttackBonus=[[0d0+@{attack_bonus}]]}} That's great! It doesn't solve the problem by itself--it still prints a "0" I don't want--but I had another attribute ready to go that I could use to shut off the printing of the attack bonus now that it doesn't generate error messages.