There are in theory two options: using an autocalc field, or a sheetworker. An autocalc field should be simpler, but I can't figure out how to get it to work, so here's the sheetworker method: First, I'd suggest putting your labels (Strength, etc) inside Label tags, so you can style them later. Also there's no good reason to use abbreviations in attribute names - it's better to use attr_Strength in place of attr_Str. Finally, for the sheetworker method, you need to remove the disabled=true tag and add readonly instead: So your html would look something like: <label>Strength</label>
<input type="number" name="attr_Strength">
<label>Mod</label>
<input type="number" name="attr_Strength_Mod" value="0" readonly> Then create a script block by adding this at the bottom of your html: <script type="text/worker">
</script>
ALL scripts you create go inside this block. Do not create multiple script blocks. A script to update the Strength mod would look like this: on("change:strength sheet:opened", function () { // stat names need to be lower case here
getAttrs(["Strength"], function(values) { // this step grabs the value of the stat
let base = parseInt(values.Strength)||0; // we store the stat in a variable so we can manipulate it. parseInt makes sure it is recognised as a number and not text.
let mod = 0; //you could change this to mod = "___"; if you want a number output for 0. But you cant use the mod in macros then, so its not a good idea.
if (base > 13) mod = base-13;
setAttrs({
"Strength_Mod": mod // save the modifier to the Strength_Mod attribute.
});
});
});
This will update the strength mod whenever strength changes. You might need to alter the calculation if there's a negative modifier for scores below 10, or if there's a maximum modifier. The script is easily tweaked. Lets say your system also give a -1 per stat below 8, the script would be tweaked to: let mod = 0;
if (base > 13) mod = base-13;
else if (base < 8) mod = base-8; Here's an alternate form of the script that will handle any number of attributes. Just change the names on the first line to whatever your attribute list is, and make sure the spelling matches perfectly. ['Strength', 'Dexterity', 'Endurance', 'Intelligence', 'Wisdom', 'Charisma'].forEach(function (name) {
on("change:" + name.toLowerCase() + " sheet:opened", function () {
getAttrs([name], function(values) {
let base = parseInt(values[name])||0;
let mod = 0;
if (base > 13) mod = base-13;
setAttrs({
[name + "_Mod"]: mod // save the modifier to the Strength_Mod attribute.
});
});
});
});