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

Negative results = automatic convert to a "0"

1411049455

Edited 1411049484
Hello I would like to know what is the formule, if any, to tell the macro to automatically show a "0" if the result is a negative number. (for example when the results of an attribute from two opponents are negative..I just need a "0") thanks for the enlightment !
1411051080
Lithl
Pro
Sheet Author
API Scripter
{0, @{target|Attribute}}kh1 ought to work.
1411051282

Edited 1411052430
Yeah well it doesnt work .. I explained myself wrong (but I expected an explanation, not a pre-made formula :) ) here is my actual formule : [[ ?{Initiative @{target|character_name}|0} - ?{Initiative @{selected|character_name}|0} ]] where I want the final result to show 0+ only. No negative.
1411052271
Pat S.
Forum Champion
Sheet Author
That I think will take the API to do. Skimmed through the wiki and couldn't find anything to suggest.
Put the whole mess into a roll comparison and add a 0d0 to the two groups to meet the roll requirement. (KH comparisons need to include some kind of roll) [[ {0d0 , 0d0 + ?{Initiative @{target|character_name}|0} - ?{Initiative @{selected|character_name}|0} }kh1 ]] Will result in a positive value if the first query is greater, and a zero if the first query is lower than the second.
1411063341
Lithl
Pro
Sheet Author
API Scripter
Mark G. said: KH comparisons need to include some kind of roll No they don't. They simply can't mix math and rolls (you must have only math values or only rolls). This works perfectly fine, I just tested it: {0,?{Initiative @{target|character_name}|0} - ?{Initiative @{selected|character_name}|0}}kh1 It can be used in either an inline roll or a regular /roll command.
Great thanks a lot !!!!
1411064949

Edited 1411064963
Brian said: Mark G. said: KH comparisons need to include some kind of roll No they don't. They simply can't mix math and rolls (you must have only math values or only rolls). This works perfectly fine, I just tested it: {0,?{Initiative @{target|character_name}|0} - ?{Initiative @{selected|character_name}|0}}kh1 It can be used in either an inline roll or a regular /roll command. what is the " 0, " used for ?
"...where I want the final result to show 0+ only. No negative." If the result is greater than zero, leave it. If it's less than zero, make it zero.
1411071374
Lithl
Pro
Sheet Author
API Scripter
Fenrilh said: Brian said: Mark G. said: KH comparisons need to include some kind of roll No they don't. They simply can't mix math and rolls (you must have only math values or only rolls). This works perfectly fine, I just tested it: {0,?{Initiative @{target|character_name}|0} - ?{Initiative @{selected|character_name}|0}}kh1 It can be used in either an inline roll or a regular /roll command. what is the " 0, " used for ? {a,b,c,d,etc...}khN will keep the highest N values from among the group {a,b,c,d}. If your group is {0, targetInitiative - selectedInitiative} and you're keeping the highest 1 value, you will get 0 if the initiative difference is negative (because 0 is higher than all negative numbers) or the initiative difference if it's positive (because all positive numbers are higher than 0).