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 syntax question

Question about syntax, ie what am I doing wrong?  Here's my problem: I'm pulling from the colored/numbered bars on a token.  I'm using this syntax:  floor(@{selected|bar3}/3)+floor(@{selected|bar2}/3) If bar3= 0 and bar2 = 5 this correctly returns 1     (0 +  trunc(5/3)) = 1 However, if bar3 is blank and bar2 = 5 this fails and returns 0.  As far as I can tell anything in the command line after an attempt to to reference bar3 when it's value is blank just doesn't execute.  No error is generated, it just doesn't happen.  If this is embedded in a longer formula everything before the reference to a blank bar works fine, everything after fails and the result returned is whatever the first part of the formula was doing.   What am I doing wrong?  Or perhaps, is there a way to force bar3 = blank to evaluate as an integer? TIA
Try adding a 0 in front of the bar value  (untested): floor(0@{selected|bar3}/3)+floor(0@{selected|bar2}/3)
1692890642
GiGs
Pro
Sheet Author
API Scripter
The issue might be that a blank cell might be being read as "" and not 0. Jarren's method fixes that.
Yep, that fixed it.  TYVM