
Not sure of the best approach and keep going back and forth trying find one I can make work. I have the following sheetworker to perform a roll from an action button: on(`clicked:roll`, () => { getAttrs(['ndice'], v=> { startRoll(`&{template:roll} {{PC=@{character_name}}} {{roll=[[4d12]]}} {{no=[[0]]}}`, (roller) => { const dice = roller.results.roll.result finishRoll( roller.rollId, { no: (+v.ndice || 0) } ); setAttrs({ low: mid: high: }); }); }); }); The button is called 'roll' and 'ndice' is always a number from 1 to 4. 'no' is just the number of dice to be outputted in the rolltemplate and not relevant to this query. So what I need it to do is: – identify the lowest value rolled and set the 'low' attribute to this value – identify the second lowest value rolled and set the 'mid' attribute to this value – identify the third lowest value rolled and set the 'high' attribute to this value However, it should only look at as many values as 'ndice' is set to and disregard the others. E.g. If the values rolled were 7, 6, 3, 9 and 'ndice' was set to 2 then low = 6 because the 3 and the 9 are irrelevant. If there aren't enough dice being rolled to have a second or third lowest then it doesn't matter what 'mid' and 'high' get set to. How can I go about this? I set the roller to always roll four dice because I thought it would be harder (or maybe impossible) to write code that could cope with referring to dice values that aren't there. Would would it actually be more feasible to have the roller only roll the required number of dice? I also wondered if it might be easier to have four separate rolls of 1d12 each.