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

If Then

Is it possible to make if/then statements in macros? Also, I would like to know if it is possible to create a macro with an exponential function. Specifically, I want a skill check in 3.5 that has ten levels of success, but each level achieved with an exponential result. So, it would be like so. Level Success 1 15 2 16 3 18 4 21 5 25 6 30 7 36 8 43 9 51 10 60 Is there any way to make a macro that will roll the skill check and then calculate the level of success?
1494217169
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Shem A. said: Is it possible to make if/then statements in macros? Also, I would like to know if it is possible to create a macro with an exponential function. Specifically, I want a skill check in 3.5 that has ten levels of success, but each level achieved with an exponential result. So, it would be like so. Level Success 1 15 2 16 3 18 4 21 5 25 6 30 7 36 8 43 9 51 10 60 Is there any way to make a macro that will roll the skill check and then calculate the level of success? There are some  rather involved macros you can do for a work around for some if/then statements, but generally, no you can't do if/then. For the skill check, that's not really exponential (having access to something like 5^10 wouldn't actually help you there), it's just adding the previous level of success number to the previous success. I'd need to know more about what goes into the overall roll to see if I can come up with a way to do it.
Shem A. said: Is it possible to make if/then statements in macros? Also, I would like to know if it is possible to create a macro with an exponential function. Specifically, I want a skill check in 3.5 that has ten levels of success, but each level achieved with an exponential result. So, it would be like so. Level Success 1 15 2 16 3 18 4 21 5 25 6 30 7 36 8 43 9 51 10 60 Is there any way to make a macro that will roll the skill check and then calculate the level of success? I think you are not sure what exponential means. However, this seems like you could use this with rollable tables. I have a lengthy description of the process here , but what you would do is: Make 10 rollable tables, named "Level1," "Level2," etc. Into each rollable table, put a single entry for the success number you want To call for one of them, use a macro that says something like "Success for Level ?{Level|1} = [[1t[Level?{Level|1}] ]] Alternatively, you could just write a mathematical formula to describe it with a WHOLE bunch of messy crap. Success For Level ?{Level|1} = [[15 + (?{Level|1}-1)+{(?{Level|1}-2),0}k1 +{(?{Level|1}-3),0}k1+{(?{Level|1}-4),0}k1+{(?{Level|1}-5),0}k1+{(?{Level|1}-6),0}k1+{(?{Level|1}-7),0}k1+{(?{Level|1}-8),0}k1+{(?{Level|1}-9),0}k1]]
1494239810

Edited 1494242549
Loki
Sheet Author
Or you just go ahead and use 15+(x*x-x)/2 or Success For Level ?{Level|1} = [[15 + (?{Level|1}-1)*(?{Level|1}/2)]] Unless you want it the other way arround, then you'd need access to sqrt (square root) which is only available in API scripts. level = Math.sqrt(Math.abs(29,75-2*Success))+0,5 The above works only for results of 15 and above thought.
Sorry, I did word that bad. I was using the term exponential in the general sense of a steady and rapid growth, not to refer to the mathematical constant or exponent functions. I apologize for the confusion. Scott did have it right, that I am just adding the previous success to the next to determine the new level. If it requires API than I do not have access to it. As to more detail of what is going into the roll, there really isn't anything else going into it. It is a basic skill check, but with the various levels of success being possible.
1494251471

Edited 1494251534
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It might not, what is the roll that gives this success? d20? d100? Something else? How is the level determined? Every 10 over a target number?
Shem A. said: Level Success 1 15 2 16 3 18 4 21 5 25 6 30 7 36 8 43 9 51 10 60 Is there any way to make a macro that will roll the skill check and then calculate the level of success? Here is a macro that does so: /r {15,16,18,21,25,30,36,43,51,60}<[[ 1d20 + ?{Mods|0} ]]
1494263024
Lithl
Pro
Sheet Author
API Scripter
Scott C. said: having access to something like 5^10 wouldn't actually help you there Loki said: sqrt (square root) which is only available in API scripts. Regular macros can achieve exponentiation with the ** operator. Square root is simply using 0.5 for the exponent. 2^8 would be 2**8 and sqrt(2) would be 2**0.5.
Silvyre That actually works perfectly. Just one last question. Will it only work as a roll, or can it be nested in a /w or /em so that only the number of successes are shown?
Sure, you could turn the /roll into an [[inline roll]]: /w gm Level [[ {15,16,18,21,25,30,36,43,51,60}<[[ 1d20 + ?{Mods|0} ]] ]]
Shem A. said: Silvyre That actually works perfectly. Just one last question. Will it only work as a roll, or can it be nested in a /w or /em so that only the number of successes are shown? Anything that starts with /r ... can be changed to [[...]] to be used as an inline roll, and vice versa. So if you want to use it with a /w or /em use [[{15,16,18,21,25,30,36,43,51,60}<[[ 1d20 + ?{Mods|0} ]]]]
1494275814
Lithl
Pro
Sheet Author
API Scripter
Kyle G. said: Anything that starts with /r ... can be changed to [[...]] to be used as an inline roll, and vice versa. Rollable tables with images don't display the image(s) for an inline roll, so not everything  can be converted like that. =)
1494276907

Edited 1494277391
Loki
Sheet Author
Brian said: Scott C. said: having access to something like 5^10 wouldn't actually help you there Loki said: sqrt (square root) which is only available in API scripts. Regular macros can achieve exponentiation with the ** operator. Square root is simply using 0.5 for the exponent. 2^8 would be 2**8 and sqrt(2) would be 2**0.5. nice, didn't know that! In that case,  try [[floor((0.25+2*(1d20-15))**0.5+0.5)]] (I'm on mobile right now and can't test it myself)
1494278985
Lithl
Pro
Sheet Author
API Scripter
Loki said: In that case,  try [[floor((0.25+2*(1d20-15))**0.5+0.5)]] Um... (0.25 + 2 * (1d20 - 15)) ** 0.5 is going to produce NaN for rolls 1-14.
Silvyre When I do that it comes up with this in the dialogue: {15,16,18,21,25,30,36,43,51,60}< (result of roll). It list the entire thing and doesn't say how many successes there were. It will work, as the information is made readily available. However, I can't get it to display the successes, such a a roll of 30 being six successes, and thus only the number 6 being displayed in the dialogue.
Never mind. I just tried it again and it works. I guess I was entering it in wrong before.
Thank you all for your assistance. My macro is working beautifully.
1494305547

Edited 1494305580
Matt
Plus
Math-only rolls Brian said: Scott C. said: having access to something like 5^10 wouldn't actually help you there Loki said: sqrt (square root) which is only available in API scripts. Regular macros can achieve exponentiation with the ** operator. Square root is simply using 0.5 for the exponent. 2^8 would be 2**8 and sqrt(2) would be 2**0.5. O_o How did I not know this? It'd be nice if someone put it on the wiki, say maybe under Math-only rolls . A pity that the wiki is not readily editable as one would expect, nor does it contain info on exponents anywhere on it...
1494310086

Edited 1494310104
Loki
Sheet Author
Brian said: Loki said: In that case,  try [[floor((0.25+2*(1d20-15))**0.5+0.5)]] Um... (0.25 + 2 * (1d20 - 15)) ** 0.5 is going to produce NaN for rolls 1-14. Yes, I hoped this was also handled by roll20's error handling as anything else - returning 0 for getting an error. [[floor((0.25+2*({0d0-0.125, (1d20) -15}k1))**0.5+0.5)]] This works thought and handels rolls below 15 correctly. Use this if you need to see the actuall roll or if you need to know if it was a failure or critical roll. (The bold part ist where your roll and modifieres go, keep everything else) Again, thank you Brian for pointing out ** works, this solves so much things I thought where impossible right now!
1494345462

Edited 1494347364
Lithl
Pro
Sheet Author
API Scripter
Matt W. said: A pity that the wiki is not readily editable as one would expect, nor does it contain info on exponents anywhere on it... It's not the wiki in general, it's articles in the  Docs category. Those articles are meant to be official Roll20 documentation, and editing is restricted to users in a group with the "docwriters" privilege. (That is,  Administrators and  contributors .) Edit: Since I am  in the "contributors" group, I've added the  Math Operators and Functions section to the Dice Reference page.