I am coding illiterate and trying to change some code a friend helped me with. I have several categories of check boxes that correspond to different dice sizes for rolls.
A dice roll consists of two dice: one determined by a number value in that skill (like speed), and another determined by checkboxes which indicate the other die size (called stress). If no boxes are checked, the number should be 10. If the "d8stress1" box is checked, then 8. If the "d6stress1" box is checked, then 6. If the "helpless" box is checked, then 4.
My best understanding is that my friend used a script to alter the number that is rolled. This number is called "invisiblestress".
A button to roll speed looks like this:
<button name="roll_speedroll" value="/roll 1d@{speed} + 1d@{invisiblestress} + ?{Add a +1?|None, 0|+1, 1|+2, 2|+3, 3}" data-sm-id="67" type="roll" class="sm-prop sm-roll" style="left: 109px; top: 883px; width: 83px; height: 33px;"></button>
The current working script looks like this (but does not include the helpless d4):
<!-- Roll20 Sheet Workers below -->
<input type="hidden" name="attr_invisiblestress" value=10>
<script type="text/worker">
on("change:d8stress1 change:d6stress1", function() {
getAttrs(["d8stress1", "d6stress1"], function(values) {
const d8 = parseInt(values.d8stress1) || 0;
const d6 = parseInt(values.d6stress1) || 0;
const result = 10 - (d8 * 2) - (d6 * 2);
setAttrs({
invisiblestress: result
});
});
});
</script>
How do I edit this to have the helpless checkbox make the result equal 4?