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 .
×

Rounding towards zero in macros

Hello! I'm having a bit of an issue with the macros I'm trying to build. I'm trying to roll a 1d100, compare it against a value (let's say 50), and every ten points below it would be a degree of success. My current macro is below. /r (?{Final check value}-d100)/10 The issue is that 2.9 degrees of success is still only 2 degrees. -2.9 is also two degrees of failure. Using the floor function gives me a -3 in the -2.9 case, which is incorrect. Is there any workaround to this, beyond using API?
1386282180

Edited 1386282290
Gauss
Forum Champion
Perhaps you can clarify what the query input is and what the expected output is. Some examples of input values as well as the expected output values would be helpful.
For example, I input the value of 50. The d100 comes out to 20. That is three degrees of success, I want to display that as 3. This works fine in the macro I have. If I input 34 and get 53, (34-53)/10= -1.9, which I want to display as -1. In other words, if I had access to the api I'd simply be forcing a conversion into an integer. Are there any alternatives in the macro system? Perhaps some math jiggering that I'm not seeing?
1386283920

Edited 1386284002
Gauss
Forum Champion
Ill try to figure something out.
Thank you. I've been trying to find some way to do this without any truncating functions (which seem to be sorely lacking in roll20), but I'm at my wits end.
1386286964
Gauss
Forum Champion
I think that other than the API there is no way to do this at this time. Sorry.
Is there a way that I am missing that allows you to reference the roll multiple times? (So as an example I could return a result with Roll^2-Roll) I think I could come up with something at that point.
1386297476
Gauss
Forum Champion
No, there is no way (outside of the API) to reference the roll multiple times.
Fair enough, thank you for the help! Suppose I'll go make a suggestion for a truncate function, shouldn't be too difficult to implement.