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

Question about roll button code

Hello all ! I can't code a roll button, I'm unable to make it display what I intend. The die is a d100 and I intend to add and display the units result (ex. on 42 the damage added is 2, on 87, it's 7)  as [RU]  to the other items (which are named  [*FOR] and [Arme] )  in the damage, displayed in the bold part below. "&{template:cmbt} {{pc=@{character_name}}} {{name=@{melee_nom} (COM)}} {{roll=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=[[@{BF}[*FOR]+(@{melee_deg})[Arme]]]}} " I think I must add $[[1]] somewhere, but I don't really understand the syntax, so all my tries have failed miserably so far. Can someone please hint me on this ?
1725036598
GiGs
Pro
Sheet Author
API Scripter
in a rolltemplate, you can't have two identical keys, which you have here: {{roll=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} (roll is used twice). The last one replaces all previous matching items, and they are discarded and not done.
thank you GiGs ! Let's suppose I rename {{roll=[[(([[1d100]]-1)%10)+1]]}} {{xyz=$[[0]]}}, is there a way I could display and add the units of the d100 roll in the damage section of the rolltemplate ? I think something like this was achieved according to this thread by adding $[[1]] in the damage part of the template, but I'm not able to get it to work :&nbsp; <a href="https://app.roll20.net/forum/post/9482193/unity-value-from-d100-roll" rel="nofollow">https://app.roll20.net/forum/post/9482193/unity-value-from-d100-roll</a>
1725037009
GiGs
Pro
Sheet Author
API Scripter
Unless there's a reason not to do it, I would have a separate result of tens and units, like "&amp;{template:cmbt} {{pc=@{character_name}}} {{name=@{melee_nom} (COM)}} {{tens=[[d10]]}} {{units=[[d10]]}} then build the output as you need to. Two bits of caution: it's best to use the default rolltemplate while working a roll out, because you know that template works, and then once the roll is working, switch to our custom rolltemplate. Also, if the roll isn't working, create it as character ability - that lets you test variations of it much more rapidly, and then when its working, add it to a roll button.
1725047407

Edited 1725057701
Fred
Pro
I need a single d100 Roll which is an attack Roll and, and if it's a hit, the units of said d100 will add to the damage done.
1725057459
GiGs
Pro
Sheet Author
API Scripter
The thing is tens and units can easily be displayed as a single d100 roll. Since you're making your own rolltemplate, you can present the tens and units how you want.
1725057853

Edited 1725057914
Fred
Pro
The problem is my rolltemplate is based on a d100 on other aspects and I'm afraid I won't be able to modify them. To be more specific : a d100 to hit is rolled. If it's a success, the damage done is the sum of 2 attributes melee_deg and bf and the units number of the d100. For example, a character succeeds on a d100 roll of 42, with melee_deg attribute of 1 and bf attribute of 3, the damage done will be 1+3+2 (units number of 42) = 6. With my actual rolltemplate I can display the sum of the 2 attributes ( melee_deg and bf ) : &amp;{template:cmbt} {{roll=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=[[@{BF}+(@{melee_deg})]]}} Below you can see it displays a 4, the sum of bf &amp; melee_deg Now if I change my rolltemplate, I can get it to display the units number of the d100 instead : &amp;{template:cmbt} {{roll=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=$[[1]]}} Below you can see it displays a 6, the units number of the d100 roll of 16 : I'd like to have my rolltemplate to be able to display in a single number the sum of the 2 attributes plus the units number of the d100 roll, do you think it is possible ?
1725071539

Edited 1725078971
GiGs
Pro
Sheet Author
API Scripter
I'm sorry, I hadn't meant to spend so many posts on this tens and units suggestion but I hadn't explained myself clearly. It's immaterial because now that I understand what you're after, I can see it won't work. Back to your question. You cannot do what you are trying to do in the way that you are doing it. In roll20 dice rolls, you cannot use the same roll to generate two different results. You are trying to use the d100 twice - once for the total, and again to calculate the tens and units: two different pieces of information. I think the only way to do what you want is to switch the Custom Roll Parsing (as described here <a href="https://cybersphere.me/guide-to-custom-roll-parsing/" rel="nofollow">https://cybersphere.me/guide-to-custom-roll-parsing/</a> ), which would mean changing your roll button to an action button and doing some of the calculation in a sheet worker. This presents a problem if you have this roll being created in lots of places with lots of different stats. It's solvable, but hard to know how to do it without seeing your entire sheet. For the record, I strongly suggest you change the name of one of your roll keys. Change this: &amp;{template:cmbt} {{roll=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=$[[1]]}} to this (or something like it) &amp;{template:cmbt} {{raw=[[(([[1d100]]-1)%10)+1]]}} {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=$[[1]]}} You can even make the roll outside of the rolltemplate like so: &amp;{template:cmbt} [[(([[1d100]]-1)%10)+1]] {{roll=$[[0]]}} {{target=[[@{COM}+(@{melee_mod})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=$[[1]]}}
No worries GiGs, your answers are helpful as usual ! I think what I wanted is adressed in the CRP:Damage Rolls in Champions of your website. Although my sheet already includes custom roll parser for other purposes (critcal/fumble), I think this modification is a little too complicated for me. I will revert to a single roll key "&amp;{template:cmbt} {{pc=@{character_name}}} {{name=@{melee_nom_bag} (COM)}} {{roll=[[1d100]]}} {{target=[[@{COM}+(@{melee_mod_bag})[Mod.]+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} {{dmg=[[@{BF}[*FOR*]+(@{melee_deg})[Arme]]]}} All you have to do is add the d100 units shown above the damage displayed.
1725139441

Edited 1725150227
GiGs
Pro
Sheet Author
API Scripter
Thanks! If you're already using CRP to calculate critical &amp; fumblr, it would be pretty easy to add the calculation you want into that worker. I'm confused how you are doing that though - CRP requires action buttons, and you have posted a roll button above.
My bad, it's just an intricate (by my standards) Roll template.
1725150308
GiGs
Pro
Sheet Author
API Scripter
unrelated to your question, you don't have to abbreviate the rolltemplate name. You have &amp;{template:cmbt} but if you change the rollteplate, you could have &amp;{template:combat}
Got it, thanks !