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

Getting dice results from multiple separate rolls in custom roll parsing

1679820230
Matthew C
Pro
Sheet Author
Hey, I have a (possibly) strange request and am using something that can probably be written WAY WAY WAY better So, before the code, some context. My system uses a number of wound/healing dice, designated when an attack is made/received etc. For the roll template I want to display each dice roll separately, this is quite annoying to write in (maybe I am doing it wrong)     on ( 'clicked:mitigationroll' , ( info ) => {         let endroll = "&{template:blank} {{name=@{character_name}'s Mitigation Roll}} {{number=[[?{number of Wound Dice|0}]]}}" +         "{{roll=[[?{number of Wound Dice|0}d10]]}} {{result=[[0]]}}" +         "{{target=[[?{Target Value?|0}]]}} {{bonus=[[?{Bonus|0} [Bonus] + @{passive_mitigation} [Mitigation Bonus] ]]}} {{penalty=[[?{penalty|0} [penalty]}}" ;         let result = [];         startRoll ( endroll , ( results ) => {             let number = results . results . number . result ;             for ( let i = 0 ; i < number ; i ++) {                 console . log ( results . results . roll . dice [ i ]);               };             finishRoll (                 results . rollId , {             });         });     }); so the issue I have is that with the above I can get and separate any number of d10s that I need (in the console), but how can I send these individual numbers to my roll template? (I do not need to send them as any specific value types, so if the roll was a 1d10=1 then sending it as a simple roll value of 1 would be fine, I have disabled the tooltips, so players do not need to see anything specific) I get the feeling that what I am trying to do is either impossible, or extremely simple (which I am really good at looking past) so thank you to anyone that can lend me a hand
1679856779

Edited 1679856909
GiGs
Pro
Sheet Author
API Scripter
If you want to send individual numbers to a rolltemplate, it's a three step process, 2 in the sheet worker, one in the rolltemplate First, each needs a separate key &{template:blank} {{name=@{character_name}'s Mitigation Roll}} {{number=[[?{number of Wound Dice|0}]]}} {{number1=[[0]]} {{number2=[[0]]} Then you need to save a computed value for each key and send it with the roll.     on ( 'clicked:mitigationroll' , ( info ) => {         let endroll = "&{template:blank} {{name=@{character_name}'s Mitigation Roll}} {{number=[[?{number of Wound Dice|0}]]}}" +         "{{roll=[[?{number of Wound Dice|0}d10]]}} {{result=[[0]]}}" +         "{{target=[[?{Target Value?|0}]]}} {{bonus=[[?{Bonus|0} [Bonus] + @{passive_mitigation} [Mitigation Bonus] ]]}} {{penalty=[[?{penalty|0} [penalty]}}" ;         let result = [];         startRoll ( endroll , ( results ) => {             let number = results . results . number . result ;             for ( let i = 0 ; i < number ; i ++) {                 console . log ( results . results . roll . dice [ i ]);               }; let computed_number1 = whatever_you_want; let computed_number2 = calculate_it_however_you_need_to;             finishRoll (                 results . rollId , { number1: computed_number1, number2: computer_number2             } );         });     }); Finally in the rolltemplate, number1 and number2 both equal 0, but they each have a hidden computed value you can access, like      number1::computed Use that whereever you would normally use number1. You need the empty keys to start with to pass these computed values to the rolltemplate. You can reuse keys that already exist (add computed values to target and bonus, for example), and if you only have one or two keys to pass that would be ideal. I added number1=[[0]] and number2=[0]] as easily expandable examples to any number of secret computed values.
1679860937
Matthew C
Pro
Sheet Author
Hey thanks for the reply Yeah I knew about how to add them to a number of "fake" rolls, by using [[0]] and then passing a new computed value, what I was hoping for was a way of passing it to the rolltemplate without first knowing how many results to make (hence the dynamic) but I am afraid that might be asking too much. I will just use something like 10 (I doubt anyone would ever get above 5) and then in the roll template have it ignore the results that equal 0 since the roll is always 1-10 Bu thanks all the same