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

Mathing in Macros?

I'm wondering if it is possible to implement the following excel formula as a macro? MAX( 1, ROUNDUP( LOG(  @{selected|bar2}  / 10, 2 ) ) + 1 )
1718258787

Edited 1718258903
GiGs
Pro
Sheet Author
API Scripter
You can do pure mathematical operations in roll20. See here for the different things you can do: <a href="https://wiki.roll20.net/Dice_Reference#Math_Operators_and_Functions" rel="nofollow">https://wiki.roll20.net/Dice_Reference#Math_Operators_and_Functions</a> Max is handled on that page but in a different place - you'd use {first, second}kh1 (notice they are curly brackets). IIRC log is a difficult function (but is still possible). Can you describe in english terms (not methematical ones) what that excel function is supposed to do, and we can tell you a suitable roll20 version. I'm asking because I'm puzzled as to why you'd need a log to base 2 of a number divided by 10 in roll20, and am wondering if you are just finding out what is possible.
1718275130

Edited 1718275686
I'm mapping a token's hitpoints into a numeric category that can be summed up by the following table: HP Macro's Output Value 1-10 1 11-20 2 21-40 3 41-80 4 81-160 5 And so on... 6+ I hope you understand now why I take the hitpoints and divide by 10 before taking log base 2. I don't expect hitpoint values less than 0 or greater than 160, but if its possible I still want the macro to return sane values.&nbsp;
1718276933
timmaugh
Forum Champion
API Scripter
Log is available with scripts, if scripts are available in your game (owner of the game must be a pro subscriber). MathOps , part of the Metascript Toolbox)has it.
1718285125

Edited 1718285253
intrinsical &nbsp;said: I'm mapping a token's hitpoints into a numeric category that can be summed up by the following table: I hope you understand now why I take the hitpoints and divide by 10 before taking log base 2. I don't expect hitpoint values less than 0 or greater than 160, but if its possible I still want the macro to return sane values.&nbsp; The dice roller can do that using ' Grouped Success ' rolls with fairly simple code: [[{1,11,21,41,81,161}&lt;@{selected|bar2}]]
That's amazing! You've solved all my problems!
1718340739
GiGs
Pro
Sheet Author
API Scripter
Jarren's technique there is worth making a note of - it comes up surprisingly often.