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

How to get a "Minimum 1" macro calculation to work?

I'm trying to make a calculation that would make it that whenever a character has a certain attribute its divided by two for a bonus (Round down), with a minimum bonus of 1.

So essentially I need something to give a value of 0, if the Attribute is 0.
1 if the attribute is 1,2 or 3.
And then go on simply dividing the number for all other values by 2, and rounding down.

I made this: 
floor((@{customa4-mod}-2)/2)+ceil(@{customa4-mod}/100))*(ceil(@{customa4-mod}/100)

and a proxy worked fine in excel, however, it just doesn't need to work in roll20. Any tips?
March 25 (7 years ago)

Edited March 25 (7 years ago)
vÍnce
Pro
Sheet Author
The Game Master said:
I'm trying to make a calculation that would make it that whenever a character has a certain attribute its divided by two for a bonus (Round down), with a minimum bonus of 1.

           That seems easy enough using group rolls with drop/keep

So essentially I need something to give a value of 0, if the Attribute is 0.
1 if the attribute is 1,2 or 3.
And then go on simply dividing the number for all other values by 2, and rounding down.
         
            This part  confuses me.  I'm not sure how that can be worked out just in a macro.
            0=0, {1,2,3}=1 and {4,5,6,...}={4,5,6,...}  is this correct?


I made this:
floor((@{customa4-mod}-2)/2)+ceil(@{customa4-mod}/100))*(ceil(@{customa4-mod}/100)

and a proxy worked fine in excel, however, it just doesn't need to work in roll20. Any tips?

This should help with making a comparison and keeping a minimum number.
https://wiki.roll20.net/Dice_Reference#Grouping_Ro... and https://wiki.roll20.net/Dice_Reference#Drop.2FKeep

I'm not sure on the other...
March 25 (7 years ago)

Edited March 25 (7 years ago)
GiGs
Pro
Sheet Author
API Scripter
Try 
/roll {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1
or 
[[ {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1 ]]
Replacing @{Stat} with your stat, obviously.

G G said:

Try 
/roll {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1
or 
[[ {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1 ]]
Replacing @{Stat} with your stat, obviously.

Thanks the latter worked great but I don't know why. Mind explaining?
March 25 (7 years ago)
Dana Lexa
Sheet Author
kh1 means keep highest 1 or "given a set of values (in a group of dice or group inside {...}), only keep the highest". So of the two values, [[ceil((@{Stat}-1)/2)]] and [[ceil(@{Stat}/1000)]], it will return the higher.

[[ceil((@{Stat}-1)/2)]] means, "subtract one from Stat, divide by two, round up". I... guess that's a way to get half rounded down, but I don't know why G G didn't just say [[floor(@{Stat}/2)]].

[[ceil(@{Stat}/1000)]] means, "divide Stat by 1000, round up", so 0 becomes 0, while 1-1001 become 1. Presumably your stats won't reach 1001 or higher.

So it's one clause that gets Stat divided by 2, the other is a 0 if Stat is 0 and a 1 otherwise, and the whole formula returns the higher of the two.
March 25 (7 years ago)
GiGs
Pro
Sheet Author
API Scripter

Author X said:

[[ceil((@{Stat}-1)/2)]] means, "subtract one from Stat, divide by two, round up". I... guess that's a way to get half rounded down, but I don't know why G G didn't just say [[floor(@{Stat}/2)]].
You're right, Floor(stat/2) is better. I outsmarted myself :)