
I'm using CRP to perform calculations on a roll. Below is the rolltemplate and sheetworker, which rolls different numbers of different-sized dice up to d10s. Currently it's set to count the total number of dice rolled as well as the frequency of each value occurring and the highest and lowest values rolled. Firstly – it's not working! Can anybody spot what's wrong with it? Secondly – really, what I need it to calculate is the second highest and third highest values rolled. What would the syntax for those functions look like? Rolltemplate: <rolltemplate class="sheet-rolltemplate-fo"> {{PC}} rolls {{name}}<br />{{computed::rolltotal}} </rolltemplate> Sheetworker: const stats = [ 'fallout' ]; fo.forEach(button => { on(`clicked:${button}`, () => { startRoll(`&{template:fo} {{name=${button}}} {{PC=@{character_name}}} {{roll=[[[[@{d4s}]]d4s+[[@{d6s}]]d6s+[[@{d8s}]]d8s+[[@{d10s}]]d10s]]}}`, (fo) => { const total = fo.results.roll.result const dice = fo.results.roll.dice //This will be an array of the values rolled on all the dice const total1s = dice.filter(d => d === 1).length; const total2s = dice.filter(d => d === 2).length; const total3s = dice.filter(d => d === 3).length; const total4s = dice.filter(d => d === 4).length; const total5s = dice.filter(d => d === 5).length; const total6s = dice.filter(d => d === 6).length; const total7s = dice.filter(d => d === 7).length; const total8s = dice.filter(d => d === 8).length; const total9s = dice.filter(d => d === 9).length; const total10s = dice.filter(d => d === 10).length; const high = Math.max(...dice); const low = Math.min(...dice); finishRoll( fo.rollId, // this is where you save the computed values into something that can be passed to rolltemplates. { rolltotal: total, one: total1s, two: total2s, three: total3s, four: total4s, five: total5s, six: total6s, seven: total7s, eight: total8s, nine: total9s, ten: total10s } ); }); }); });