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

Macro which Ignores "No Attribute Found" error and completes equation without attribute.

To clarify, I would like to create an equation that references an attribute which a character may or may not have.

  • If the character does have the attribute, then it should add the attribute value into the equation,
  • if the character does not have the attribute, then it should ignore it and parse the equation as if the attribute was zero or not called at all.

For Example

[[@{selected|strength} + @{selected|dexterity} + @{selected|boost}]]

  • All characters have the attributes dexterity and strength.
  • Hansel has the attribute boost
  • Gretel does not have the attribute boost.

When Hansel is selected and the macro is run the result should be the sum of the attributes "strength + dexterity + boost"

When Gretel is selected and the same macro is run, the result should be the sum of the attributes "strength + dexterity + 0" or perhaps just "strength + dexterity"

However

When I run the macro for Hansel it works, but when I run it for Gretel it just gives me the "No Attribute Found" error and does not return a result. 


Any Ideas how I can get the macro to ignore not finding an attribute and run the way I described in the examples?

Thank you.

July 06 (3 years ago)

https://app.roll20.net/forum/post/9253685/ignore-error-options

[[0@{selected|strength} + 0@{selected|dexterity} + 0@{selected|boost} &{noerror}]]


Jarren said:

https://app.roll20.net/forum/post/9253685/ignore-error-options

[[0@{selected|strength} + 0@{selected|dexterity} + 0@{selected|boost} &{noerror}]]

So I actually tried something similar, based off another post. That line you sent works just fine by itself, but I am trying to use it in a larger macro, here is the latest variation of what I tried based on your feedback:

?{whisper|yes,/w gm|no,} &{template:default} {{name=Accuracy}} {{Threshold=[[0@{selected|Martial} + 0@{selected|Perception} + 0@{selected|boost} &{noerror}]]}} {{Proficiency= [[0@{selected|boost} &{noerror}]]}} {{Difficulty=?{Difficulty|0}}} {{Check Result=[[floor(ceil((0@{selected|Martial} + 0@{selected|Perception} +  0@{selected|boost} - ?{Difficulty|0} - 1d100+0.1)/20)*1.01-0.005) &{noerror}]]}}

Now it does not show the error, but it also doesn't send any results to chat. I appreciate your feedback and hope its just an amateur syntax mistake that someone can point out or that there is another solution. 

Thanks again. 



July 07 (3 years ago)

I’m not at my computer so I can’t verify, but it might be your first whisper query. Try adding a space after the ‘/w gm, and after the ‘no’. Or try the macro without that query and see if it posts in chat. 

?{whisper|yes,/w gm |no, }

Then try posting each section in chat, adding another chunk and seeing where you no longer get a result. 

?{whisper|yes,/w gm |no, } &{template:default} {{name=Accuracy}} {{Threshold= }} 
?{whisper|yes,/w gm |no, } &{template:default} {{name=Accuracy}} {{Threshold=[[0@{selected|Martial} + 0@{selected|Perception} + 0@{selected|boost} &{noerror}]]}} 


July 07 (3 years ago)
Kraynic
Pro
Sheet Author

I would say don't put a space after the no, and also remove the space after the query.  If the answer is no, there should be no spaces before the &{template.

?{whisper|yes,/w gm |no,}&{template:default} {{name=Accuracy}} {{Threshold= }}

The "0@{selected|boost}" in the final check result needs to be inside a nested roll

[[0@{selected|boost}]]

When the "boost" attribute doesn't exist it gets replaced by the text "selected|boost". Since that's not valid macro syntax it treats it and everything after it as a roll comment. This works for the simple rolls since there is nothing in the roll after the attribute. But in the Check Result the roll doesn't end there and most importantly the closing brackets for the floor and ceil functions appear after the attribute and as such are treated as comment. Since those functions don't get closed it errors badly/silently. Putting that particular attribute inside a nested roll avoids the rest of the outer roll being treated as a roll comment when it's missing.

If any of the other attributes can be missing they should also be in nested rolls.

Thank you all, I will test these out first chance I get and respond with the troubleshooting results!

July 11 (3 years ago)
David M.
Pro
API Scripter

That's a gem, RainbowEncoder! Allowed me solve an unrelated issue, thanks!

I can confirm that RainbowEncoder's solution is effective and I have employed it to resolve my previously described errors; I appreciate everyone taking the time to share their knowledge and thank you all for your assistance.