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

Is it possible to convert [[Roll result]] to plain text in a macro/ability?

November 10 (4 years ago)

Edited November 10 (4 years ago)

While working on some macros and abilities I ended up falling upon a useful little hack, and was wondering... how could I further make use of it?

You can create a series of macros/abilities... for example:

#Macro which has the content:

Somepart of the macro
#SubMacro@{CharName|level}
Another part of the macro

#SubMacro1
#SubMacro2
#SubMacro3
etc

When you use #Macro, it first expands the attribute "level" before calling the SubMacro, and will then call the matching SubMacro to your level. e.g. If the character has the attribute level which is equal to 2, #Macro will do whatever else you have it do, then expand and execute #SubMacro2

I was wondering... could we do that with some sort of math, comparison, or randomness that require rolls?
So I tried the easiest test

#Macro which now has text:

Somepart of the macro
#SubMacro[[1d3]]
Another part of the macro

But that doesn't work, instead it writes in chat "#SubMacro" with the roll result of whatever the die ended up.

Is it possible to, in the macro, convert the roll result value to plain text to have it call the correct SubMacro?

November 10 (4 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter

Not sure it will be possible due to the order of operations.

Rolls are executed after attributes and macros have been expanded, even if those result in roll syntax the actual rolls themselves aren't run until after the macro triggers have finished.

November 10 (4 years ago)
Oosh
Sheet Author
API Scripter

As Ziechael says, it's just not possible. You can do this with API buttons and with image links though, they come after the math in order of operations:

[Random Attack](~macros|attack[[1d10]])

Will create a button with a link to a macro from attack1 to attack10.

November 10 (4 years ago)

Edited November 10 (4 years ago)

Ah, right, forgot all the expansion was done before rolls.

And, thank you. Albeit not ideal to what I was hoping, that will totally work.


Thanks everyone!