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

[Help] How can I turn this into something that automatically calculates itself in a character sheet?

1516186489

Edited 1516186532
Khoa P.
Sheet Author
The Damage Bonus is derived from adding two stats together and looking at the table. How can I turn this into something that automatically calculates itself in a character sheet? Thanks.
1516188333

Edited 1516214694
GiGs
Pro
Sheet Author
API Scripter
You'll need a sheet worker, set up to change the DMG bonus when SIZ and STR change. You'll need to add a scripts section at the end of your character sheet like this, <!-- SHEET WORKERS --> <script type="text/worker"> </script> Any sheet workers you create go between those two tags. Here's one for the damage bonus, assuming your stats are named STR and SIZ, and damage bonus is stored in an attribute called DMG: on("change:str change:siz", function() { // stat names must use lower case here     getAttrs(["STR", "SIZ"], function(pvalue) { // from here on, use the actual case of the stat names.     var curStrength = parseInt(pvalue.STR);     var curSize = parseInt(pvalue.SIZ);     var STRplusSIZ = curStrength + curSize;     var DBonus;                              //Determine Bonus             if (STRplusSIZ < 13) {             DBonus = "-1d6";             }             else if (STRplusSIZ < 18) {             DBonus = "-1d4";             }             else if (STRplusSIZ < 25) {             DBonus = "0";             }             else if (STRplusSIZ < 32) {             DBonus = "1d4";             }             else { var damageFactor = Math.ceil((STRplusSIZ-24)/16);             DBonus = damageFactor + "d6";             }             setAttrs({ DMG: DBonus // change the DMG attribute name here to whatever your damage bonus attribute is called }); }); }); There are several already-existing BRP/RQ compatible character sheets in the  github repository . It's good practice to ransack their code for other things you might need.
Thank you so much! I didn't even know Sheet Workers were a thing. Yeah, I need to check them out. I'm trying to work on the Basic Roleplaying Sheet, but I'm pretty new to coding sheets in general.
1516214747
GiGs
Pro
Sheet Author
API Scripter
I just noticed i had a couple of unused variables in the code i provided, I've cleaned it up.
If you are working on the BRP sheet, you may want to talk to Carl T . See this thread: <a href="https://app.roll20.net/forum/post/5961625/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/5961625/slug%7D</a>
1516273753
David
Sheet Author
Thank you so much! I didn't even know Sheet Workers were a thing. Yeah, I need to check them out. I'm trying to work on the Basic Roleplaying Sheet, but I'm pretty new to coding sheets in general. Well if you had checked with me I could have gave I could have given you sheet workers for Damage Bonus, Category Bonuses, Strike Ranks and Hit Points.&nbsp;