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

Sheet Workers - Counting successes

1720711926
Jeremy H.
Pro
Sheet Author
Hello! I am working on a character sheet for a game, and I'm attempting to do something a little complicated. I want to set up a Sheet Worker in a character sheet to be able to, when referenced, count successes and display (in a new text block in chat) how many successes the roll generated? For example, I've managed to do this in the API. But, ideally I'd want people to be able to use my sheet without the API. The reason I'm attempting to accomplish this is, in the game system, it's a d12 success-based system, where rolling a 12 on a d12 counts as two  successes instead of just one. I've seen previous forum posts about setting up rollable tables, but I would really rather not do that (as that'd force people wanting to use my custom sheet to do pre-set up in order to play the game). How would I go about setting up a Sheet Worker to do this? Is it even possible?
1720719068
Andreas J.
Forum Champion
Sheet Author
Translator
Sounds like you want to do this with <a href="https://wiki.roll20.net/Custom_Roll_Parsing" rel="nofollow">https://wiki.roll20.net/Custom_Roll_Parsing</a> Apart from rolling a 12 on the d12 resulting in 2 successes, what are the other outcomes?
1720721210
Jeremy H.
Pro
Sheet Author
Andreas J. said: Sounds like you want to do this with <a href="https://wiki.roll20.net/Custom_Roll_Parsing" rel="nofollow">https://wiki.roll20.net/Custom_Roll_Parsing</a> Apart from rolling a 12 on the d12 resulting in 2 successes, what are the other outcomes? 1 - 7 = 0 Success 8 - 11 = 1 Success 12 = 2 Successes That's all I'm looking for, really.
1720724965

Edited 1727046413
GiGs
Pro
Sheet Author
API Scripter
As Andreas says, you definitely want Custom Roll Parsing. You'll find a detailed guide for that here <a href="https://cybersphere.me/guide-to-custom-roll-parsing/" rel="nofollow">https://cybersphere.me/guide-to-custom-roll-parsing/</a> Yes, it is possible, and if you can create scripts in the API, it should even be fairly trivial for you. Without knowing more details about the roll (how do you dice how many dice to roll, are there ever any modfiers to the roll or to the successes), it' hard to suggest a worker. The simplest form would be something like this: on ( 'clicked:my_button' , () =&gt; { &nbsp; &nbsp; const roll_string = "&amp;{template:default} {{my_roll=[[3d12]]}}" ; &nbsp; &nbsp; startRoll ( roll_string , roll =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; let total = 0 ; &nbsp; &nbsp; &nbsp; &nbsp; roll . results . my_roll . dice . forEach ( die =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( die &gt;= 12 ) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += 2 ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else if ( die &gt;= 8 ) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += 1 ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; finishRoll ( roll . rollID ,{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll : total &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; }) }); Or compactified a bit: on ( 'clicked:my_button' , () =&gt; { &nbsp; &nbsp; const roll_string = "&amp;{template:default} {{my_roll=[[3d12]]}}" ; &nbsp; &nbsp; startRoll ( roll_string , roll =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; const total = roll . results . my_roll . dice . reduce (( sum , die ) =&gt; sum + ( die &gt;= 12 ? 2 : ( die &gt;= 8 ? 1 : 0 )), 0 ); &nbsp; &nbsp; &nbsp; &nbsp; finishRoll ( roll . rollID ,{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll : total &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; }) }); Then in your rolltemplate (with CRP, you always need a custom roll template), you can get the successes using the computed property - just use {{computed:my_roll}} instead of&nbsp; anumber.