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 Question: Negative Modifiers and Floor()

1438117932

Edited 1438117974
I made a homebrew and I'm trying to write up some macros for the players to use in the Abilities section of the Character sheets. The problem I'm having is with negative modifiers. For example: Bob has a STR modifier of -1. When Bob rolls STR checks sometimes the macro that is used displays a negative number (-1). Here's what the macro looks like: &{template:default} {{name= Strength}} {{Check/ST= [[1d20 +@{STR Modifier} ]] | [[1d20 +@{STR Modifier} ]]}} What I want to do is make sure that the macro only displays a 0 (zero) instead of negative numbers if the result happens to be a negative number. I've tried using floor() but I can't tell if it's just nullifying the modifier since it is a negative number in the first place. Here's what I've tried. &{template:default} {{name= STR}} {{Check/ST= [[1d20 +(@{STR Modifier} (floor (0))) ]] | [[1d20 +(@{STR Modifier} (floor (0))) ]]}} Any help would be appreciated. Thank you.
1438119024

Edited 1438119111
Silvyre
Forum Champion
The drop/keep function would suit you better here. &{template:default} {{name= Strength}} {{Check/ST= [[ {1d20 +@{STR Modifier}, 0d0}k1 ]] | [[ {1d20 +@{STR Modifier}, 0d0}k1 ]]}}
Thanks. That worked. I'll have to read why now.
1438132117
Lithl
Pro
Sheet Author
API Scripter
Silvyre said: The drop/keep function would suit you better here. &{template:default} {{name= Strength}} {{Check/ST= [[ {1d20 +@{STR Modifier}, 0d0}k1 ]] | [[ {1d20 +@{STR Modifier}, 0d0}k1 ]]}} This isn't what you want; this is keeping the higher value of "d20+STR" and "0d0". It only even makes a difference at all if STR is -2 or lower, and even then only if you roll low on the d20. What you want is to use this for the rolls: [[1d20 + {@{STR Modifier}, 0}k1]] The C, there are two other things I'd like to mention about your initial attempt: The floor() function is a rounding  function, turning fractional numbers into whole numbers. Specifically, it rounds the number towards negative infinity. 2.6 becomes 2, 1.3 becomes 1, and -0.25 becomes -1. floor() will never ever turn a negative number into a positive number or zero. You seem to be trying to use a strange combination of Polish notation and infix notation to try and use floor(). floor() accepts a single argument, which should be between the parentheses: "floor(@{Strength Modifier})", not "(@{Strength Modifier} floor(0))". The former functions (even if it's not the solution you need in this case), the latter isn't even syntactically correct.
1438134610

Edited 1438134738
Silvyre
Forum Champion
Brian said: What you want is to use this for the rolls: [[1d20 + {@{STR Modifier}, 0}k1]] The C. said: I made a homebrew [...] What I want to do is make sure that the macro only displays a 0 (zero) instead of negative numbers if the result happens to be a negative (Emphasis mine.) It only even makes a difference at all if STR is -2 or lower, and even then only if you roll low on the d20. I infer The C. is attempting to account for such edge cases.
Brian said: Silvyre said: The drop/keep function would suit you better here. &{template:default} {{name= Strength}} {{Check/ST= [[ {1d20 +@{STR Modifier}, 0d0}k1 ]] | [[ {1d20 +@{STR Modifier}, 0d0}k1 ]]}} This isn't what you want; this is keeping the higher value of "d20+STR" and "0d0". It only even makes a difference at all if STR is -2 or lower, and even then only if you roll low on the d20. What you want is to use this for the rolls: [[1d20 + {@{STR Modifier}, 0}k1]] The C, there are two other things I'd like to mention about your initial attempt: The floor() function is a rounding  function, turning fractional numbers into whole numbers. Specifically, it rounds the number towards negative infinity. 2.6 becomes 2, 1.3 becomes 1, and -0.25 becomes -1. floor() will never ever turn a negative number into a positive number or zero. You seem to be trying to use a strange combination of Polish notation and infix notation to try and use floor(). floor() accepts a single argument, which should be between the parentheses: "floor(@{Strength Modifier})", not "(@{Strength Modifier} floor(0))". The former functions (even if it's not the solution you need in this case), the latter isn't even syntactically correct. Thanks for the explanations.