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

Problem with a Macro

March 09 (11 years ago)

Edited March 09 (11 years ago)
Hello, everyone!
I wanted to design a specific Macro: First, four different abilities should be summed up and then divided by 5. That works out just fine. Next thing is: I want to roll 1d20, which can be modified, against that value. And there's the rub: It doesn't work. The two components alone (calculating the value and rolling the modified dice) seem to work, alas combined they decided not to. This is my formula:
/roll {1d20 + ?{Modi}}<{@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5
I'm at a loss. Any advice?
put the section before and after the < in parenthesis not curly braces
March 09 (11 years ago)

Edited March 09 (11 years ago)
If I do it like this, then the result of the roll won't be compared to the second value - I only get (for example) 7+10=17. It would be nice to see if it was a success.
March 10 (11 years ago)

Edited March 10 (11 years ago)
I messed with this a fair bit and it doesn't look like the < or > operators accept anything but a single number value on the right side of the comparison.

ie: you can't calculate the right side.
Feared so. That means I have to get creative. ;D
Thank you nonetheless for the fast replies!
March 10 (11 years ago)
Roger A.
Sheet Author
If you put the 1d20+ ?{modifier} in an inline roll [[1d20+ ?{modifier}]] , and move it to the other side of the comparator, then put your other rolls inside a group with {roll 1, roll2, etc} in front of the comparator it should give you the results you want.
Okay, I tried it out, but Roll20 persists to name it an "Unrecognized command"...
when I tested this, I tried many different combinations and operators on the right-side of the < equation.
[5] [[ 5 ]] (5) {5} ,etc to verify what, if any, grouping or calculation brackets would be recognized; let alone an actual calculation.

Nothing but a straight-up numeric value was accepted on the right-side.
March 12 (11 years ago)

Edited March 12 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Roger told you how to do it, kind of, but it's very easy to mess up the brackets.
Here's one way that works:
/roll 1d20<[[(@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH})/5 - ?{Modi}]]
You do need to rearrange the terms a bit.

Edit: this works too.
/roll {1d20+?{Modi}}<[[(@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH})/5]]


I really must be slipping. If that works, then it'll be the third post I've been corrected on recently :)
Ahhh well.
March 13 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Don't feel bad! getting a macro to do this is far from intuitive in roll20, I couldn;t figure it out when i first arrived here and someone else (the awesome Gauss) pointed out how its done.
Sorry to disappointyou, but it seems like roll20 hates me: neither the first nor the second formula works...
March 13 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Did you copy and paste them exactly?
I tested those macros on my sandbox campaign and they worked fine. What error did you get?

I'm trying to think of what might be making it fail.
Are you creating them as campaign macros, or as character sheet abilities?

You need to have a token selected, and the selected token needs to be linked to a character sheet with the stats, MU, KL, and CH, and those stats must have a value in them. If they are blank, roll20 will fail - you must have a number (even if 0) in them.


Yes, I did copy and paste. I used them as character-macros and the selected token was linked to a sheet with all stats (and their values).
Okay, great news: I started to play with your formula and after a few changes it suddenly worked - don't ask why, but adding another ability to the formula made it run smoothly. I'm stunned. ;D
March 15 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Yay! Glad to hear it.
March 16 (11 years ago)

Edited March 16 (11 years ago)
... The only thing is that it doesn't work if the second roll is decimal number (like 13,999)...
March 17 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Are you using commas for decimal place? Try using full stop/period (.). It may be that roll20 only supports the english/american notation, and thinks 13,999 is a word, not a number.
The problem is the equation: {@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5 - sometimes the values have decimal places. And IF there is such a number, than the formula won't work.
But I found a solution: Two Macros, one for the potential decimal number, the other for the roll. My players are intelligent enough to round numbers - or at least I hope so. ;D
March 17 (11 years ago)
Lithl
Pro
Sheet Author
API Scripter

Conny F. said:

The problem is the equation: {@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5 - sometimes the values have decimal places. And IF there is such a number, than the formula won't work.

You can surround this in floor(...) (to round down) or ceil(...) (to round up). To round in either direction (eg, 0.7 rounds up, 0.3 rounds down), use floor, but add 0.5 to the value.

  • floor({@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5) -- 13.999 becomes 13
  • ceil({@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5) -- 13.111 becomes 14
  • floor({@{selected|MU}+@{selected|MU}+@{selected|KL}+@{selected|CH}}/5 + 0.5) -- 13.111 becomes 13 and 13.999 becomes 14
Brian, G G, Mark G. - you are my personal heroes!
March 19 (11 years ago)
GiGs
Pro
Sheet Author
API Scripter
Thanks! Glad we could help :)