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

Help with Dice Pool Macro

Hi, there! I have this macro: &{template:default} {{tested=[[?{Status|Regular, 1d20|Advantage, 2d20kh1|Disadvantage, 2d20kl1}+?{Modifier|0}]]}} I NEED to replace d20 for a d6 dice pool, like: {5d6!}>4 , that works perfectly in chat. So, I've tried this: &{template:default} {{tested=[[?{Status|Regular, {5d6!}>4|Advantage, {5d6!}>3|Disadvantage, {5d6!}>5}+?{Modifier|0}]]}} But it doesn't work at all... Also, I want to replace the "5" for an Attribute of the Character Sheet. Is it possible to make it right or there is a limitation to the Roll20 system? Can anyone help me get it right? Thank you all!!!
1665956417

Edited 1665956699
Gauss
Forum Champion
For the first problem, every time you have {5d6!} the "}" is telling the query "?{Status|Regular,....." that the query is done.  So the query sees:  ?{Status|Regular, {5d6!} and that is the end of the query.  To fix that you have to use HTML entities:  "}" is the same as "}" (without quotes) &{template:default} {{tested=[[?{Status|Regular, {5d6!}>4|Advantage, {5d6!}>3|Disadvantage, {5d6!}>5}+?{Modifier|0}]]}} For the second request:  &{template:default} {{tested=[[?{Status|Regular, {@{charactername|attributename}d6!}>4|Advantage, {@{charactername|attributename}d6!}>3|Disadvantage, {@{charactername|attributename}d6!}>5}+?{Modifier|0}]]}} Note: you cannot use HTML entities on the attributes without breaking them, but in my testing the above macro works. Replace "charactername" with either selected or with the character's name. Replace "attributename" with the name of the attribute you want to use.
1665957171

Edited 1665957232
GiGs
Pro
Sheet Author
API Scripter
Using } brackets inside a query is not easy because the macro reads them as the end of the query. (There are other characters to avoid too). Those characters can be replaced with HTML Characters, which for } are } or }. But that has its own pitfalls. Another thing you can do is rearrange the expresions so the query doesnt contain those } symbols. You can do that with your macro, like this: &{template:default} {{tested=[[ {5d6!}>?{Status|Regular,4|Advantage,3|Disadvantage,5}+?{Modifier|0}]]}} Its important that the query doesnt contain any spaces - whatever is placed in the query will appear after the > symbol. If you want to put attribute calls in there, thats easy: &{template:default} {{tested=[[ {5d6!}>?{Status|Regular,@{attribute}|Advantage,3|Disadvantage,5}+?{Modifier|0}]]}} The wiki has the different ways of including an attribute call. If you want to include a calculation, you can, for instance &{template:default} {{tested=[[ {5d6!}>?{Status|Regular,@{attribute}+1|Advantage,3+2|Disadvantage,5}+?{Modifier|0}]]}} Spaces usually don't matter, but you should avoid them in the calculation above unless you enclose the query in inline roll brackets, like &{template:default} {{tested=[[ {5d6!}>[[ ?{Status|Regular, @{attribute} + 1|Advantage, 3 + 2|Disadvantage, 5} ]]+?{Modifier|0}]]}}
1665957629
GiGs
Pro
Sheet Author
API Scripter
Gauss said: Note: you cannot use HTML entities on the attributes without breaking them This is correct. Never replace any symbols in an attribute call. This is due to the roll20 order of operations. Attribute calls are resolved before the rest of the macro (including html substitution), so roll20 needs to see the proper name of the attribute - if you have replaced any attributes with html entities, Roll20 will try to look for @{attribute} which is not the proper name of the attribute and will fail.
Hi, there! Thank you both so much, Gauss and GiGs! I've put the first sugestion (from Gauss) on a button, inside the character sheet: <button type="roll" value="&{template:default} {{name=@{character_name}}} {{tested=[[?{Status|Regular, {@{power}d6!}>4|Advantage, {@{power}d6!}>3|Disadvantage, {@{power}d6!}>5}+?{Modifier|0}]]}}"> </button> It doesn't work. What have I done wrong?
1665964007
GiGs
Pro
Sheet Author
API Scripter
I'd suggest skipping that and try my version. It's not worth fiddling with html entities when you can avoid it. &{template:default} {{name=@{character_name}}} {{tested=[[ {@{power}d6!}>[[ ?{Status|Regular, 4|Advantage, 3|Disadvantage, 5} ]]+?{Modifier|0}]] Note that this will only work as an Ability in the character. If it's a general macro, you'll need to change @{character_name} and @{power} to add a character name, like @{bilbo|power} or @{selected|power}
GiGs said: I'd suggest skipping that and try my version. It's not worth fiddling with html entities when you can avoid it. &{template:default} {{name=@{character_name}}} {{tested=[[ {@{power}d6!}>[[ ?{Status|Regular, 4|Advantage, 3|Disadvantage, 5} ]]+?{Modifier|0}]] Note that this will only work as an Ability in the character. If it's a general macro, you'll need to change @{character_name} and @{power} to add a character name, like @{bilbo|power} or @{selected|power} My friend, it worked like a charm!!! It's just perfect!!! THANK YOU, so much!!! This helped me a lot!!! God bless!!!
1665973946
Gauss
Forum Champion
@Zartmann, I was only devising a macro for you, not a character sheet button. I don't do character sheet coding. :)
1665984141
GiGs
Pro
Sheet Author
API Scripter
If i remember correctly, there's a bug with roll buttons, that macros containing a html entity need an extra level of nesting. I may be misremembering, I avoid using htm entities as much as possible, but that rings a bell.
Gauss said: @Zartmann, I was only devising a macro for you, not a character sheet button. I don't do character sheet coding. :) I know, but I needed the Macro too and your input was flawless!!! Thank you so much!!!
GiGs said: If i remember correctly, there's a bug with roll buttons, that macros containing a html entity need an extra level of nesting. I may be misremembering, I avoid using htm entities as much as possible, but that rings a bell. Yeah, I can't wait till the roll20 system is based only on plain javascript, hahahahahaha! Then I'll be able to code whatever I want!!!
Zartmann Drakhos said: GiGs said: If i remember correctly, there's a bug with roll buttons, that macros containing a html entity need an extra level of nesting. I may be misremembering, I avoid using htm entities as much as possible, but that rings a bell. Yeah, I can't wait till the roll20 system is based only on plain javascript, hahahahahaha! Then I'll be able to code whatever I want!!! Or simple "drag and drop" to any user (hello, Astral VTT, I'm dreaming about you!). We are all in the 21st century... c'mon, hahahahahahaha!!!
GiGs said: I'd suggest skipping that and try my version. It's not worth fiddling with html entities when you can avoid it. &{template:default} {{name=@{character_name}}} {{tested=[[ {@{power}d6!}>[[ ?{Status|Regular, 4|Advantage, 3|Disadvantage, 5} ]]+?{Modifier|0}]] Note that this will only work as an Ability in the character. If it's a general macro, you'll need to change @{character_name} and @{power} to add a character name, like @{bilbo|power} or @{selected|power} Hello, there!!! How are you, guys??? <button type="roll" value="&{template:default} {{name=@{character_name}}} {{tested Power=[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]]}} {{damage=[[@{weapon_damage}+@{rank}}]]}}"></button> The button is working beautifully and I wanted to know if i s it possible to sum the result of  the section  {{tested Power=[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]]}} into this section  {{damage=[[@{weapon_damage}+@{rank}}]]}}  Each success is a damage point, so if I have 3 successess, they will be added to {{damage=[[@{weapon_damage}+@{rank}}]]}} . So, considering "weapon_damage" is 2 and "rank" is 4, I would get a total of 9. Thank you!!!
1668103221
timmaugh
Roll20 Production Team
API Scripter
There are "reusing rolls" tricks that can get pretty involved, but you might be able to get by with a straightforward application... The easiest way to reuse rolls is to recall internal (nested) rolls from a more complex, existing roll. So if your final roll would add the successes, damage, and rank, you would probably start with that as the generation of all of your roll data, then recall the internal (simpler) ones as needed. The full roll would be: [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] +  [[@{weapon_damage}+@{rank}}]]]] Presented another way to show the component parts: [[ + ]]    [[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] [[@{weapon_damage}+@{rank}}]] So you could put that between your template parts and reference the rolls as necessary. Without testing it, I would read the internal marker indices as requiring something like: <button type="roll" value="&{template:default}  [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] + [[@{weapon_damage}+@{rank}}]]]]  {{name=@{character_name}}} {{tested Power=$[[1]]}} {{damage=$[[0]]}}"></button> If you wanted to include the base damage (before you added the successes to it), that should be roll marker $[[3]], so you could add that to another template part, if you wanted to present that. If you ever need to sus out what roll is represented by what roll marker index, you can just output the roll in a standard default template: &{template:default} [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] + [[@{weapon_damage}+@{rank}}]]]] {{name=Roll Marker Autopsy}} {{Roll0=$[[0]]}} {{Roll1=$[[1]]}} {{Roll2=$[[2]]}} ...with as many roll parts as you need.
timmaugh said: There are "reusing rolls" tricks that can get pretty involved, but you might be able to get by with a straightforward application... The easiest way to reuse rolls is to recall internal (nested) rolls from a more complex, existing roll. So if your final roll would add the successes, damage, and rank, you would probably start with that as the generation of all of your roll data, then recall the internal (simpler) ones as needed. The full roll would be: [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] +  [[@{weapon_damage}+@{rank}}]]]] Presented another way to show the component parts: [[ + ]]    [[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] [[@{weapon_damage}+@{rank}}]] So you could put that between your template parts and reference the rolls as necessary. Without testing it, I would read the internal marker indices as requiring something like: <button type="roll" value="&{template:default}  [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] + [[@{weapon_damage}+@{rank}}]]]]  {{name=@{character_name}}} {{tested Power=$[[1]]}} {{damage=$[[0]]}}"></button> If you wanted to include the base damage (before you added the successes to it), that should be roll marker $[[3]], so you could add that to another template part, if you wanted to present that. If you ever need to sus out what roll is represented by what roll marker index, you can just output the roll in a standard default template: &{template:default} [[[[{@{power}d6!}>[[?{Status|Normal, 4|Advantage, 3|Disadvantage, 5}]]]] + [[@{weapon_damage}+@{rank}}]]]] {{name=Roll Marker Autopsy}} {{Roll0=$[[0]]}} {{Roll1=$[[1]]}} {{Roll2=$[[2]]}} ...with as many roll parts as you need. Fantastic!!! That's a whole new level of possibilities!!! I'm gonna test them all!!! Thank you so much!!!