<div class="sheet-wrapper">
<div class="sheet-2colrow">
<div class="sheet-col">
<h3>Attribtes:</h3>
<div class="sheet-row">
<div class="sheet-item sheet-thirtypercent"><label>Strength:</label></div>
<div class="sheet-item sheet-sixteenpercent"><input type="number" name="attr_str" value="5" /></div>
</div>
<div class="sheet-row">
<div class="sheet-item sheet-thirtypercent"><label>Gun Recoil:</label></div>
<div class="sheet-item sheet-sixteenpercent"><input type="number" name="attr_recoil" value="0" /></div>
<div class="sheet-item sheet-thirtypercent"><label>Recoil Mod:</label></div>
<div class="sheet-item sheet-sixteenpercent"><input type="number" name="attr_recoilmod" value="0" /></div>
</div>
</div>
</div>
</div>
<script type="text/worker">
on("change:str change:recoil sheet:opened", function() {
getAttrs(["STR","RECOIL","RECOILMOD"], function(values) {
let tempstr = parseInt(values.STR);
let temprecoil = parseInt(values.RECOIL);
let temprecoilmod = parseInt(values.RECOILMOD);
if (temprecoil > tempstr) {
let temprecoilmod = temprecoil-tempstr;
} else {
let temprecoilmod = 0;
}
setAttrs({
"recoilmod": temprecoilmod
});
});
});
</script> So I've thrown together a tiny sheet above to mess about with this sheet worker that won't work. I've got a wopnderful Character Sheet & CSS all working fine but I need sheetworkers to help with the following: A PC has a Strength (str) score. Their gun has a Recoil (recoil) score. If a gun's recoil > str, then the player has a penalty (recoilmod = recoil-str) on their attack. Else there is no penalty (recoilmod = 0) But my sheetworker does nothing. I've played with different things. I've moved the script into the <div></div> tags & renamed every attribute and still no effect. Also one of hte help files showed parseInt(values.RECOIL)||0 so I tried that, but don't understand what the '||0' does. Any help would be appreciated - I assume it's something simple.