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

Help Request with rounding down to the nearest whole number - didn't see this in wiki

How can I make this formula round down to the nearest whole number? [[((@{selected|level}+4)/4)]] Thank you! Barry
1474035752
Alicia
Sheet Author
Try  [[floor((@{selected|level}+4)/4)]]
Thank you Alicia, However when I add a dice roll to it :[[floor((@{selected|level}+4)/4))d8]] with a referenced level of 1, I always get a roll of 2, instead of an expected roll of 1d8 ((1+4)/4= 1 d8) Any suggestions? Barry
1474039341
The Aaron
Pro
API Scripter
Do you get the right values without the d8?
Even when I subtract the d8 from the roll, I continue to receive a "2". Here is the complete macro I am using, is there possibly a conflict? *@{selected|token_name} invokes the name of @{selected|god} while speaking forth a prayer...* /w GM ***and casts SACRED FLAME!! The attack caused [[floor((@{selected|level}+4)/4))d8]] points of RADIANT damage unless a successful DC [[0d0 + 8 + @{selected|PB} [proficiency] + @{selected|wisdom_mod} [wisdom]]] dexterity save is made!!*** !token-mod {{ --set bar3_value|[[ {@{selected|bar3}-.5,0}kh1 ]] --ids @{selected|token_id} }} /fx burn-fire @{target|token_id}
1474040347
Tetsuo
Forum Champion
Use [[[[floor((@{selected|level}+4)/4))]]d8]] instead. Adding the extra set of inline brackets makes sure it resolves everything inside of them before attempting to resolve the d8 portion.
That fixed it Franky! Thank you so much!
1474040804
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I tried to replicate your issue just putting in various numbers for @{selectedlevel}. Each time, it's dropping the d8 part of the inline roll. If I take out "floor" so that the roll is just [[((@{selectedlevel} + 4)/4)d8]], then it properly applies the d8 to the inline roll. It looks to me that there is a bug in the inline roller that is preventing math functions from being used in the number of dice for a XdY roll. A minimum example replicating this bug: [[(floor(1))d8]] ^ Always returns 1.
1474045591
The Aaron
Pro
API Scripter
Interesting!  That brings up another point which is dice are always integers, so you don't need the floor function in this case, it will be implicitly truncated to just the integer part if it has a decimal portion.
The Aaron said: That brings up another point which is dice are always integers, so you don't need the floor function in this case, it will be implicitly truncated to just the integer part if it has a decimal portion. Actually, the number of dice is simply rounded as per round(). e.g. /r (1.49)d1 + (1.51)d1 resolves to equal 3
1474049604
The Aaron
Pro
API Scripter
Ah!  So subtract .5 and that should work.