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

New sheet in development - need help with skill roll button

1642165916

Edited 1642166346
Hi, I am creating a new character sheet for a new TTRPG. I started a few days ago and I am trying to figure out how to correctly get the skill dice roll result I want. The roll is calculated this way: [Skill Dice Pool] - [Negative Modifier] d6 > 4 But players can have focuses. For example, skill crafting, focus blacksmithing. It isn't a flat bonus, but if you failed (rolled 3 or under) in any of the dice you can replace up to 2 of them with a success. Example: Dice pool of 5 (skill dice pool 7 and negative modifier 2 for example): (1, 5, 3, 6, 4), so 3 successes.+1 focus applies in this case so the result is 4 successes Example 2: Dice pool of 5: (5, 5, 6, 4, 5), so 5 successes. Since no dice failed, +1 focus cannot be applied and the result is 5 successes. So my question is: What would be the best way of coding that into the character sheet? What I did so far: < button type = "roll" name = "roll_crafting" value = "&{template:testtemplate} {{name=Crafting}} {{roll=[[(@{crafting-dice-pool} -@{negative-modifier})d6>4 + ?{Focus|0} ]]}}" ></ button > I can't do it this way. I would like the player to be able to input his own focus number, but the above code is going to add that number every time, regardless of the maximum number of successes. I thought I could use a custom roll function. < button type = "action" name = "act_roll_crafting" > Roll </ button > but that would require me to create a sheet worker on button click event for each skill. I need to set a few variables for the roll template, such as the name of the skill and the skill dice pool (the negative modifier would be the same for all skills so I could just get that value easily) These are my questions: Is there a way to avoid using the action button? Can I somehow code the standard roll macro to achieve what I want? If I need to use the action button, how can I pass parameters such as skill name and base dice pool - so I can use the same roll function for all of the skills to avoid code repetition? --- I could create a function for every button and those parameters would be defined in that function, and then passed into another function, the roll function, to reuse a big chunk of the code, but it still seems a bit excessive to have a separate on click event for every button. Is that really the best solution? Is there another solution I did not think of?
1642172520
David
Sheet Author
const abilitybuttonlist = ["connoisseur","first_aid","photography","nativelang","abilitychoice"]; abilitybuttonlist.forEach(button => { on(`clicked:${button}`, (info) => { let skill = info.triggerName.substring('clicked:'.length); doFunction(skill); }); })
1642177571
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I would recommend the action button. You name the button after the skill that it is for (e.g.act_athletics). Then in the listener you do a getAttrs to get the values of the dice pool and the applicable focus. Initiate the startroll, edit the results as needed, and you're good to go.
Thank you for your help, both of you