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

How do I change the calculation for the attribute modifiers on roll20?

Hi I'm a little new here and I'm currently in the process of trying to make a custom character sheet for a TTRPG me and my friends have been working on for a bit. Though I can only get so far just looking and/or copying what other people do and youtube videos, I wanted to know if there was a way to do this. Because calculations for us is more like, whatever your score is divide it by 5 and you have your modifier with the minimum your score can be being a 5, yknow like that. I'd like any source or hell even pointing me in the right direction of finding someone who can help me
1653771249

Edited 1653773130
vÍnce
Pro
Sheet Author
Without knowing exactly how your game's calculations and attributes are setup, it's hard to give precise calculations... but just a quick example going off of what you described above, this might work; inline roll example; [[ { 5, round(@{stat1}/5) + @{mod1} }kh1 ]] used in a sheet button <button type="roll" name="roll_stat1" value="[[ { 5, round(@{stat1}/5) + @{mod1} }kh1 ]]" ></button> Some references from the wiki that might help: Math Operators and Functions Grouping Rolls Maybe post what you've tried that isn't working.
Oh well you see, being as how I've been learning on how to, I got a random HTML sheet from the public github and have been editing it big time as a starting point for me. Uhhh, I don't exactly know how to show what I'm working on, I'm trying to just find the calcs on this sheet, its just something called "Darker Dungeons 5e" or somethin vÍnce said: Without knowing exactly how your game's calculations and attributes are setup, it's hard to give precise calculations... but just a quick example going off of what you described above, this might work; inline roll example; [[ { 5, round(@{stat1}/5) + @{mod1} }kh1 ]] used in a sheet button <button type="roll" name="roll_stat1" value="[[ { 5, round(@{stat1}/5) + @{mod1} }kh1 ]]" ></button> Some references from the wiki that might help: Math Operators and Functions Grouping Rolls Maybe post what you've tried that isn't working.
1653777237

Edited 1653777287
vÍnce
Pro
Sheet Author
AFAIK, the 5e sheet does most of it's attribute calculations using sheetworkers.  Knowing that, the Darker Dungeons sheet probably does this as well which makes it more difficult to figure out what is happening unless you have at least a basic understanding of javascript.  Given that most/all the sheet attributes are probably being calculated within the sheetworkers, is there a particular calculation that you want to change?
Oh, huh. Well I just wanted to change how the modifiers for the core attributes, (STR, DEX, INT, etc) are changed, and through that learn how to change the main modifier calculations
1653780226

Edited 1653780739
vÍnce
Pro
Sheet Author
With a quick look at the sheet's code on roll20's repo , I'm thinking that this snippet of code (line 8468 and 8929) may handle the ability mod calcs. // line 8468 var update_mod = function(attr) { getAttrs([attr], function(v) { var attr_abr = attr.substring(0, 3); var finalattr = v[attr] && isNaN(v[attr]) === false ? Math.floor((parseInt(v[attr], 10) - 10) / 2) : 0; var update = {}; update[attr + "_mod"] = finalattr; update["npc_" + attr_abr + "_negative"] = v[attr] && !isNaN(v[attr]) && parseInt(v[attr], 10) < 10 ? 1 : 0; setAttrs(update); }); }; // line 8929 var parseValues = function(uses_string) { var attribs = ["strength", "dexterity", "constitution", "wisdom", "intelligence", "charisma"]; uses_string = uses_string ? uses_string.toLowerCase() : ""; _.each(attribs, function(attrib) { var attribMod = Math.floor((parseInt(currentData[attrib + "_base"]) - 10) / 2); if (attribMod < 0 || isNaN(attribMod)) attribMod = 0; uses_string = uses_string.replace(attrib, attribMod); }); uses_string = uses_string.replace(/half_level/g, Math.floor(classlevel / 2)); return uses_string.replace(/level/g, classlevel); }; That said, someone that is more familiar with the sheet and/or javascript will probably have to assist beyond this point. ;-)
I get ya, however I really do appreciate all you've helped me with thus far! This was a great experience, I'll see what I can do from here and if I have any other questions concerning similar matters. I'll see if I can get help then
I did find that! However I would like to know what would I need to change for the calcs to the be the one's I want, like earlier as I said the whole thing with the score divided by 5 should be the calc
1653781225

Edited 1653781241
vÍnce
Pro
Sheet Author
You could try replacing the code from above; "- 10) / 2)" to "/5)" and see what happens.  This could work for changing the mod, but might break another calc on the sheet... Twist the knobs and see what happens. ;-)
1653782971

Edited 1653782981
GiGs
Pro
Sheet Author
API Scripter
I havent looked at the sheet, but from those 2 snippets, it looks like it calculates the modifiers in a fairly convoluted way. I wonder if there's a simpler D&D-based sheet to use as base. I would try Vince's suggestion, with one small correction: "- 10) / 2)" to "/5))" That is in both sheet workers.
I tried that and close but no cigar. What happened was that the sheet just stopped auto-calculating things whenever a score was changed, so I would change a score from 15 to 20 and the modifier wouldn't change from what it was originally. Truth be told if there's a simpler sheet out there, because I have 0 knowledge in coding but I have enough yknow insight to read something and put 2 and 2 together
1653798976
vÍnce
Pro
Sheet Author
I did a quick test.  As GiGs pointed out, I didn't have the parenthesis properly setup. I substituted ") - 10) / 2)" with ") ) / 5)" and it seems to calc as expected for me. Line 8471 var finalattr = v[attr] && isNaN(v[attr]) === false ? Math.floor((parseInt(v[attr], 10) ) / 5) : 0; Line 8933 var attribMod = Math.floor((parseInt(currentData[attrib + "_base"]) ) / 5);
1653801462
GiGs
Pro
Sheet Author
API Scripter
That looks correct. Maybe the best way is to list the full lines. That allows some optimisation. This var finalattr = v[attr] && isNaN(v[attr]) === false ? Math.floor((parseInt(v[attr], 10) - 10) / 2) : 0; should be updated to var finalattr = v[attr] && isNaN(v[attr]) === false ? Math.floor(parseInt(v[attr]) / 5) : 0; And this var attribMod = Math.floor((parseInt(currentData[attrib + "_base"]) - 10) / 2); becomes var attribMod = Math.floor(parseInt(currentData[attrib + "_base"]) / 5);
Oh wow, okay lemme start trying to mess around with these as the wise code wizards advised, lol, but really appreciate it. I'm sorry I couldn't reply faster, had things come up
Oh wow! Okay so all the attributes are working as intended currently which honestly is a god send but now the skills aren't necessarily working (acrobatics, etc)
1653946567
vÍnce
Pro
Sheet Author
The Tey said: Oh wow! Okay so all the attributes are working as intended currently which honestly is a god send but now the skills aren't necessarily working (acrobatics, etc) Not sure...  They appear to work for me. Have you changed any other code?
Well you see, in the particular campaign I'm running, the scores go by different names -- Strength = Vigor Dexterity = Agility Constitution = Soul Intelligence = Intellect Wisdom = Wisdom (that didnt change) Charisma = Mystique and I found a way to change the names of the attribute scores however I don't know if that really messed with anything. I have a checklist of what I need to find and change to fit the minimum basics of the campaign I'm currently running
I'm pretty sure I found a fix? Which is instead of renaming every single instance, I just renamed the "Button" labels and it seemed to work out