Calling on the Aaron.... I need your expertise. I am trying to replace an auto-calc with a sheetworker using the TAS. The auto-calc <div class="sheet-cell sheet-col2">
<input type="text" name="attr_level" disabled="disabled" value="[[@{difficulty}*1]]" />
</div>
<div class="sheet-cell sheet-col2">
<select name="attr_base">
<option value="@{current_strength}">ST</option>
<option value="@{current_dexterity}">DX</option>
<option value="@{current_intelligence}">IQ</option>
<option value="@{current_health}">HT</option>
<option value="@{willpower}">Will</option>
<option value="@{perception}">Per</option>
<option value="10">10</option>
</select>
</div>
<div class="sheet-cell sheet-col2">
<select name="attr_difficulty">
<option value="-1 + @{base} + @{bonus} + @{enc} + (floor((@{points} * 0.25) + 2) * ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) + @{points} * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ) * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ))">
E</option>
<option value="-2 + @{base} + @{bonus} + @{enc} + (floor((@{points} * 0.25) + 2) * ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) + @{points} * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ) * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ))">
A</option>
<option value="-3 + @{base} + @{bonus} + @{enc} + (floor((@{points} * 0.25) + 2) * ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) + @{points} * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ) * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ))">
H</option>
<option value="-4 + @{base} + @{bonus} + @{enc} + (floor((@{points} * 0.25) + 2) * ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) + @{points} * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ) * abs( ceil( ( ( @{points} - 2 ) + abs( @{points} - 2) ) / 256 ) - 1 ))">
VH</option>
<option value="-4 + @{base} + @{bonus} + @{enc} + (floor( (floor( @{points} / 3) * 0.25) + 2) * ceil( ( ( floor( @{points} / 3) - 2 ) + abs( floor( @{points} / 3) - 2) ) / 256 ) + floor( @{points} / 3) * abs( ceil( ( ( floor( @{points} / 3) - 2 ) + abs( floor( @{points} / 3) - 2) ) / 256 ) - 1 ) * abs( ceil( ( ( floor( @{points} / 3) - 2 ) + abs( floor( @{points} / 3) - 2) ) / 256 ) - 1 ))">
WC</option> <!-- rebuild as sheetworker -->
</select>
</div>
<div class="sheet-cell sheet-col2">
<input type="number" name="attr_bonus" value="0" placeholder="0" />
</div>
<div class="sheet-cell sheet-col2">
<input type="number" name="attr_points" value="0" placeholder="0" />
</div> The new code: // Update Lines on Skills
on("change:repeating_skills remove:repeating_skills change:current_strength change:current_dexterity change:current_intelligence change:current_health change:willpower change:perception change:current_conditions change:skillRoll_mod change:encumbrance_level", function () {
TAS.repeating("skills")
.attrs("current_strength", "current_dexterity", "current_intelligence", "current_health", "willpower", "perception", "skillRoll_mod", "encumbrance_level", "skillRoll_mod" )
.fields("difficulty", "bonus", "points",
"level", "enc_penalty", "enc", "baseattr" )
.each(function (r, a) {
r.D[0].enc_penalty = r.F.enc * a.F.encumbrance_level;
if (r.S.baseattr === "ST") {
r.D[0].base = a.F.current_strength;
} else if (r.S.baseattr === "DX") {
r.D[0].base = a.F.current_dexterity;
} else if (r.S.baseattr === "IQ") {
r.D[0].base = a.F.current_intelligence;
} else if (r.S.baseattr === "HT") {
r.D[0].base = a.F.current_health;
} else if (r.S.baseattr === "Will") {
r.D[0].base = a.F.willpower;
} else if (r.S.baseattr === "Per") {
r.D[0].base = a.F.perception;
} else if (r.S.baseattr === "Ten") {
r.D[0].base = 10;
}
if (r.S.difficulty === "E") {
r.D[0].level = a.F.skillRoll_mod + -1 + r.F.base + r.F.bonus + r.F.enc + (Math.floor((r.F.points * 0.25) + 2) * Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) + r.F.points * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ) * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ));
} else if (r.S.difficulty === "A") {
r.D[0].level = a.F.skillRoll_mod + -2 + r.F.base + r.F.bonus + r.F.enc + (Math.floor((r.F.points * 0.25) + 2) * Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) + r.F.points * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ) * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ));
} else if (r.S.difficulty === "H") {
r.D[0].level = a.F.skillRoll_mod + -3 + r.F.base + r.F.bonus + r.F.enc + (Math.floor((r.F.points * 0.25) + 2) * Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) + r.F.points * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ) * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ));
} else if (r.S.difficulty === "V") {
r.D[0].level = a.F.skillRoll_mod + -4 + r.F.base + r.F.bonus + r.F.enc + (Math.floor((r.F.points * 0.25) + 2) * Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) + r.F.points * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ) * Math.abs( Math.ceil( ( ( r.F.points - 2 ) + Math.abs( r.F.points - 2) ) / 256 ) - 1 ));
} else if (r.S.difficulty === "W") {
r.D[0].level = a.F.skillRoll_mod + -4 + r.F.base + r.F.bonus + r.F.enc + (Math.floor( (Math.floor( r.F.points / 3) * 0.25) + 2) * Math.ceil( ( ( Math.floor( r.F.points / 3) - 2 ) + Math.abs( Math.floor( r.F.points / 3) - 2) ) / 256 ) + Math.floor( r.F.points / 3) * Math.abs( Math.ceil( ( ( Math.floor( r.F.points / 3) - 2 ) + Math.abs( Math.floor( r.F.points / 3) - 2) ) / 256 ) - 1 ) * Math.abs( Math.ceil( ( ( Math.floor( r.F.points / 3) - 2 ) + Math.abs( Math.floor( r.F.points / 3) - 2) ) / 256 ) - 1 ));
}
})
.execute();
});