I am trying to set a weapon's damage based on how many hands hold it and a special notation for the weapon. So if the weapon has note 9 and is held 2 handed standard it is 1d12 damage, but if held 1 handed standard it is 1d10 damage.
Here is the sheetworker I have so far:
<script type="text/worker">
on("change:weaponspec_1 change:weaponhand_1 change:weapondmg_1 sheet:opened", function() {
getAttrs(["WeaponSpec_1","WeaponHand_1","WeaponDmg_1"], function(values) {
let weaponspec_1 = parseInt(values.WeaponSpec_1)||0;
let weaponhand_1 = parseInt(values.WeaponHand_1)||0;
let modifier;
// the scale
if (weaponspec_1 == 9 && weaponhand_1 == 1) modifier = "1d12";
else if (weaponspec_1 == 9 && weaponhand_1 == 0) modifier = "1d10";
setAttrs({weapondmg_1 : modifier});
});
});
</script>
Here is the standard weapon entry:
<input type="hidden" name="attr_WeaponToggle_1" value="0" class="showStuff" />
<table class="hiddenTable">
<tr>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">EV</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Range</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Ammo</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Note</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Trait</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Type</td>
</tr>
<tr>
<td><input type="number" name="attr_WeaponEV_1" STYLE="width: 40px" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponRange_1" class="short alcenter" value="0" /></td>
<td>
<select name="attr_WeaponAmmo_1" STYLE="width: 60px;font-size: 10px" class="short alright">
<option value="Melee" selected="selected">Melee</option>
<option value="Thrown" >Thrown</option>
<option value="Arrow" >Arrow</option>
<option value="Bolt" >Bolt</option>
<option value="Stone" >Stone</option>
</select>
</td>
<td>
<select name="attr_WeaponSpec_1" STYLE="width: 47px;font-size: 10px" class="short alright">
<option value="0" selected="selected">NA</option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
<option value="6" >6</option>
<option value="7" >7</option>
<option value="8" >8</option>
<option value="9" >9</option>
<option value="10" >10</option>
<option value="11" >11</option>
</select>
</td>
<td>
<select name="attr_WeaponTrait_1" STYLE="width: 47px;font-size: 10px" class="short alright">
<option value="0" selected="selected">NA</option>
<option value="*" >*</option>
<option value="@" >@</option>
<option value="*@" >*@</option>
</select>
</td>
<td>
<select name="attr_WeaponType_1" STYLE="width: 63px;font-size: 10px" class="short alright">
<option value="Blunt" selected="selected">Blunt</option>
<option value="Slash" >Slash</option>
<option value="Pierce" >Pierce</option>
<option value="Fire" >Fire</option>
<option value="Cold" >Cold</option>
<option value="Acid" >Acid</option>
<option value="Electric" >Electric</option>
<option value="Poison" >Poison</option>
</select>
</td>
</tr>
</table>
<table class="hiddenTable">
<tr>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Attr</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">BtH +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Mod +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Misc +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Magic</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">= Total</td>
</tr>
<tr>
<td>
<select name="attr_WeaponHitAttr_1" STYLE="width: 75px;font-size: 10px" class="short alright">
<option value="0" selected="selected">NA</option>
<option value="1" >STR</option>
<option value="2" >DEX</option>
<option value="3" >CON</option>
<option value="4" >INT</option>
<option value="5" >WIS</option>
<option value="6" >CHA</option>
</select>
</td>
<td><input type="number" name="attr_WeaponBth_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponHitMod_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponHitMisc_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponHitMagic_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponHitTotal_1" class="short alcenter" value="0" /></td>
</tr>
</table>
<table class="hiddenTable">
<tr>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Attr</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Dmg +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Mod +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Misc +</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Magic</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">= Total</td>
</tr>
<tr>
<td>
<select name="attr_WeaponDmgAttr_1" STYLE="width: 75px;font-size: 10px" class="short alright">
<option value="0" selected="selected">NA</option>
<option value="1" >STR</option>
<option value="2" >DEX</option>
<option value="3" >CON</option>
<option value="4" >INT</option>
<option value="5" >WIS</option>
<option value="6" >CHA</option>
</select>
</td>
<td><input type="text" name="attr_WeaponDmg_1" class="short alcenter" value="1d0" /></td>
<td><input type="number" name="attr_WeaponDmgMod_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponDmgMisc_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponDmgMagic_1" class="short alcenter" value="0" /></td>
<td><input type="number" name="attr_WeaponDmgTotal_1" class="short alcenter" value="0" /></td>
</tr></table><table class="hiddenTable">
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Hand</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Magic</td>
<td class="bluehilite boldme alcenter" style="background-color:maroon;color:gold;text-shadow:2px 2px 2px #000000;">Slayer</td>
</tr>
<tr>
<td>
<select name="attr_WeaponHand_1" STYLE="width: 95px;font-size: 10px" class="short alright">
<option value="0" selected="selected">1H Standard</option>
<option value="1" >2H Standard</option>
<option value="3" >1H Prime</option>
<option value="6" >1H Off</option>
</select>
</td>
<td><select name="attr_WeaponMagical_1" STYLE="width: 55px;" class="short alright"> <option value="0" selected="selected">No</option>
<option value="1" >Yes</option></select><td><input type="text" name="attr_WeaponSlayer_1" width="75" STYLE="width: 75px" size="0" class="short" value="None" /></td>
</tr>
</table>
</div>