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
This post has been closed. You can still view previous posts, but you can't post any new replies.

Is there a round() function for macros?

Is there a function for macros similar to ceil() and floor() that just does a normal round? If not, I think this would be a great addition. Consider the following macro: [[d20+0.25*@{STR}]] This macro will print out a decimal response not very useful for most RPGs: e.g. 10.25 If I use ceil(): [[d20+ceil(0.25*@{STR})]] then a player with 1STR incorrectly gets the same bonus as someone with 4STR. Using floor() results in a similar problem. A round() function would be a simple addition that would fit nicely with the ceil() and floor() functions.
Wow, after some guessing, it appears that there actually is a round() function, it is just not documented anywhere I could find it. I suggest that a dev add it to the Dice Reference . For others who may stumble across this post: [[round(1.25)]] = 1 [[round(1.5)]] = 2 [[round(1.75)]] = 2
Cool. Nice discovery! :)
1410037187
Lithl
Pro
Sheet Author
API Scripter
John said: I suggest that a dev add it to the Dice Reference . Why don't you? =)
1410158493
Gauss
Forum Champion
I have added it to the Dice Reference.
I was looking around the other day for something like this. Nice find. I can also add a little bit to this. If you have a fraction for a formula determining how many die to roll, it seems to round up automagically. For instance, I was making a macro to calculate my Channel Positive Energy die using this macro: Where Level is the character's channeling level; /roll (@{Selected|Level}/2)d6 of damage. Thus, when Level=1, it yielded a 1d6 roll, Level=3 yields 2d6 and so-on. I'm not sure if this is an official rounding function, or just an unintended side effect hat could change?
1410274588

Edited 1410274777
Lithl
Pro
Sheet Author
API Scripter
Ryan P. said: If you have a fraction for a formula determining how many die to roll, it seems to round up automagically. Actually, the system uses round-to-nearest, not round-up when determining the number of dice to use. After all, rolling half of a die makes no sense*. Your example will always be rounding up because you're dividing by 2, which will always result in a 0.5 fractional part, which is rounded up with round-to-nearest. However, if you tried a formula which was dividing by 3, you'd see that it also rounds down when appropriate. =) * Unless you're Cohen the Barbarian trying to roll a 7 on a 6-sided die.
There are floor and ceiling functions, as well.
1410340207
Lithl
Pro
Sheet Author
API Scripter
John was aware of floor and ceil, but he wanted round. =)