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?
1522006662

Edited 1522007729
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. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This part&nbsp; confuses me.&nbsp; I'm not sure how that can be worked out just in a macro. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0=0, {1,2,3}=1 and {4,5,6,...}={4,5,6,...}&nbsp; 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. <a href="https://wiki.roll20.net/Dice_Reference#Grouping_Ro" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Grouping_Ro</a>... and <a href="https://wiki.roll20.net/Dice_Reference#Drop.2FKeep" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Drop.2FKeep</a> I'm not sure on the other...
1522007609

Edited 1522007644
GiGs
Pro
Sheet Author
API Scripter
Try&nbsp; /roll {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1 or&nbsp; [[ {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1 ]] Replacing @{Stat} with your stat, obviously.
G G said: Try&nbsp; /roll {[[ceil((@{Stat}-1)/2)]],[[ceil(@{Stat}/1000)]]}kh1 or&nbsp; [[ {[[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?
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,&nbsp;[[ceil((@{Stat}-1)/2)]] and&nbsp;[[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.
1522015832
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 :)