Hey all, as the title says, not new to programming, but I already hate working with sheet workers and trying to learn the syntax. Below is what I have: <div class="sheet-advanced__cell">
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Acuity</div>
<input type="number" min="1" max="10" name="attr_acuity" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Vitality</div>
<input type="number" name="attr_vitality" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Nerve</div>
<input type="number" name="attr_nerve" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Essence</div>
<input type="number" name="attr_essence" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
</div>
<div class="sheet-advanced__cell">
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Durability</div>
<input type="number" name="attr_durability" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Agility</div>
<input type="number" name="attr_agility" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Comprehension</div>
<input type="number" name="attr_comprehension" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
<div name="shell" class="sheet-bordered sheet-advancedJustify">
<div class="sheet-centertitle sheet-stamina1">Discernment</div>
<input type="number" name="attr_discernment" value="1" class="sheet-currentStamina sheet-stamina2 sheet-centered">
</div>
</div> As you can see here, they are simply a bunch of statistics that I want to limit between a 1 and a 10, but using the html min max does not do this, so I looked into sheetworkers and basically have this: <script type="text/worker">
on('change:vitality', () => {
getAttrs(['vitality'], v=> {
let vital = parseInt(v.vitality) || 0;
let score = (vital > 10) ? 10 : (vital < 1 ? 1 : vital);
setAttrs({
vitality: score
}, {silent:true});
});
});
</script> But this would need to be made each time for each stat and what I would want is this (pseudo code) <script type="text/worker">
on('change:vitality change:durability change(the rest)', () => { getAttrs(['THE ATTRIBUTE CHANGED THAT CALLED THE SHEET WORKER'], v=> {
let stat = parseInt(v.STAT THAT WAS CHANGED) || 0;
let score = (stat > 10) ? 10 : (stat < 1 ? 1 : stat);
setAttrs({
STAT THAT CHANGED: score
}, {silent:true});
});
});
</script> and from what I understand sheet workers do record exactly which attribute called a sheet worker so I do believe this should be possible, but I am not sure where to start, any help to this or a huge document with advanced sheetworker thingies would be awesome. the roll20 page for sheetworkers explains things but does not have enough examples of unique situations