I am trying to create a script for when the player selects the name of the weapon from the list, the other fields are automatically filled, but something is not working, could someone help? <!--Weapon table start-->
<label class="sheet-weapongrouptable">Tabela de ataques</label>
<div class="sheet-tablebody">
<div>
<div class="sheet-weapontablerow1 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponname">Nome</br></label></div>
<div class="sheet-weapontablerow2 weapontablefirstline"><label class="sheet-selectedweapons sheet-weapontype">Proficiência</label></div>
<div class="sheet-weapontablerow3 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponnivel">Nível</label></div>
<div class="sheet-weapontablerow4 weapontablefirstline"><label class="sheet-selectedweapons sheet-weapondamage">Dano</label></div>
<div class="sheet-weapontablerow5 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponrange">Alcance padrão</label></div>
<div class="sheet-weapontablerow6 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponrangemax">Alcance máx.</label></div>
<div class="sheet-weapontablerow7 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponcalibre">Calibre</label></div>
<div class="sheet-weapontablerow8 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponrdf">RDF</label></div>
<div class="sheet-weapontablerow9 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponammo">Pente</label></div>
<div class="sheet-weapontablerow10 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponweight">Peso</label></div>
<div class="sheet-weapontablerow11 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponstrenght1hand">Força mín(1mão)</label></div>
<div class="sheet-weapontablerow11 weapontablefirstline"><label class="sheet-selectedweapons sheet-weaponstrenght2hand">Força mín(2mãos)</label></div>
</div>
<fieldset class="repeating_weaponselection">
<select name="attr_weaponname">
<option class="sheet-weapongrouplevel" value="0" selected>N/A</option>
<option class="sheet-weapongrouplevel" value="1" selected>Tantalum</option>
</select>
<input type="number" class="sheet-weapontablerow2 sheet-inputweaponproperty" name="attr_weaponprof" value="0">
<input type="number" class="sheet-weapontablerow3 sheet-inputweaponproperty" name="attr_weaponnivel" value="0">
<input type="number" class="sheet-weapontablerow4 sheet-inputweaponproperty" name="attr_weapondamage" value="0">
<input type="number" class="sheet-weapontablerow5 sheet-inputweaponproperty" name="attr_weaponrange" value="0">
<input type="number" class="sheet-weapontablerow6 sheet-inputweaponproperty" name="attr_weaponrangemax" value="0">
<input type="number" class="sheet-weapontablerow7 sheet-inputweaponproperty" name="attr_weaponcalibre" value="0">
<input type="number" class="sheet-weapontablerow8 sheet-inputweaponproperty" name="attr_weaponrdf" value="0">
<input type="number" class="sheet-weapontablerow9 sheet-inputweaponproperty" name="attr_weaponammo" value="0">
<input type="number" class="sheet-weapontablerow9 sheet-inputweaponproperty" name="attr_weaponweight" value="0">
<input type="number" class="sheet-weapontablerow11 sheet-inputweaponproperty" name="attr_weaponstrength1hand" value="@{weaponweight}/0.2" disabled="true">
<input type="number" class="sheet-weapontablerow12 sheet-inputweaponproperty" name="attr_weaponstrength2hand" value="@{weaponweight}/0.7" disabled="true">
<button type="roll" class="sheet-weapontablerow11" value="&{template:tagmar_rolagem_completa} {{title_battle=@{weaponname}}} {{charname=@{nomepersonagem}}} {{subtags=@{racapersonagem} | @{profissaopersonagem}}} {{subinformacao=@{weapondamagetype}}} {{dano1=[[@{weapon25d}+@{weapondamagebonus}]]}} {{dano2=[[@{weapon50d}+@{weapondamagebonus}]]}} {{dano3=[[@{weapon75d}+@{weapondamagebonus}]]}} {{dano4=[[@{weapon100d}+@{weapondamagebonus}]]}} {{dano5=[[@{weapon125d}+@{weapondamagebonus}]]}} {{dano6=[[@{weapon150d}+@{weapondamagebonus}]]}} {{dano7=[[@{weapon175d}+@{weapondamagebonus}]]}} {{dano8=[[@{weapon200d}+@{weapondamagebonus}]]}} {{dano9=[[@{weapon225d}+@{weapondamagebonus}]]}} {{dano10=[[@{weapon250d}+@{weapondamagebonus}]]}} {{dano11=[[@{weapon275d}+@{weapondamagebonus}]]}} {{dano12=[[@{weapon300d}+@{weapondamagebonus}]]}} {{coluna=[[?{Bônus ou penalidade:|0}+@{weaponbonus}+[[@{weapontotal}+?{Tipo de defesa do alvo?|L, @{weaponL&#125;|M, @{weaponM&#125;|P, @{weaponP&#125;}]]-?{Modificador de defesa?|0} ]]}} {{d20=[[1d20]]}} {{falha=Falha}} {{rotineiro=0% │ 0}} {{facil=25% │ [[@{weapon25d}+@{weapondamagebonus}]]}} {{medio=50% │ [[@{weapon50d}+@{weapondamagebonus}]]}} {{dificil=75% │ [[@{weapon75d}+@{weapondamagebonus}]]}} {{muitodificil=100% │ [[@{weapon100d}+@{weapondamagebonus}]]}} {{muitodificil+=125% │ [[@{weapon125d}+@{weapondamagebonus}]]}} {{critico=Crítico}} {{falha+20=Falha}} {{rotineiro+20=50% │ [[@{weapon50d}+@{weapondamagebonus}]]}} {{facil+20=75% │ [[@{weapon75d}+@{weapondamagebonus}]]}} {{medio+20=100% │ [[@{weapon100d}+@{weapondamagebonus}]]}} {{dificil+20=125% │ [[@{weapon125d}+@{weapondamagebonus}]]}} {{muitodificil+20=150% │ [[@{weapon150d}+@{weapondamagebonus}]]}} {{muitodificil++20=175% │ [[@{weapon175d}+@{weapondamagebonus}]]}} {{critico+20=Crítico}} {{falha+40=Falha}} {{rotineiro+40=100% │ [[@{weapon100d}+@{weapondamagebonus}]]}} {{facil+40=125% │ [[@{weapon125d}+@{weapondamagebonus}]]}} {{medio+40=150% │ [[@{weapon150d}+@{weapondamagebonus}]]}} {{dificil+40=175% │ [[@{weapon175d}+@{weapondamagebonus}]]}} {{muitodificil+40=200% │ [[@{weapon200d}+@{weapondamagebonus}]]}} {{muitodificil++40=225% │ [[@{weapon225d}+@{weapondamagebonus}]]}} {{critico+40=Crítico}} {{descricao=@{atackextrainformations}}}" ></button> </div>
</fieldset>
</div>
</div>
<script type="text/worker">
//Set Active Defense, Movement, and Description according to the Maneuver value
on("sheet:opened change:repeating_weaponselection_weaponname", function() {
getAttrs(["repeating_weaponselection_weaponname", "repeating_weaponselection_weaponprof", "repeating_weaponselection_weaponnivel", "repeating_weaponselection_weapondamage", "repeating_weaponselection_weaponrange","repeating_weapon_calibre","repeating_weaponselection_weaponrdf","repeating_weaponselection_weaponammo", "repeating_weaponselection_weaponheight", "repeating_weaponselection_weaponstreght1hand", "repeating_weaponselection_weaponstrength2hand"], function(value) {
if (value.weaponname === "0") {
console.log("Setting repeating_weaponselection_weaponprof, repeating_weaponselection_weaponnivel, repeating_weaponselection_weapondamage,repeating_weaponselection_weaponrange,repeating_weaponselection_weaponweaponcalibre,repeating_weaponselection_weaponrdf, repeating_weaponselection_weaponammo, repeating_weaponselection_weaponheight, repeating_weaponselection_weaponstrenght1hand, repeating_weaponselection_weaponstrength2hand");
setAttrs({repeating_weaponselection_weaponprof: " ",
repeating_weaponselection_weaponnivel: " ",
repeating_weaponselection_weapondamage: " ",
repeating_weaponselection_weaponrange: " ",
repeating_weaponselection_weaponcalibre: " ",
repeating_weaponselection_weaponrdf: " ",
repeating_weaponselection_weaponammo: " ",
repeating_weaponselection_weaponheight: " ",
repeating_weaponselection_weaponstrenght1hand: " ",
repeating_weaponselection_weaponstrenght2hand: " "});
}
else if (value.weaponname === "1") {
console.log("Setting repeating_weaponselection_weaponprof, repeating_weaponselection_weaponnivel, repeating_weaponselection_weapondamage,repeating_weaponselection_weaponrange,repeating_weaponselection_weaponweaponcalibre,repeating_weaponselection_weaponrdf, repeating_weaponselection_weaponammo, repeating_weaponselection_weaponheight, repeating_weaponselection_weaponstrenght1hand, repeating_weaponselection_weaponstrength2hand");
setAttrs({repeating_weaponselection_weaponprof: "Energia",
repeating_weaponselection_weaponnivel: "@{energia} ",
repeating_weaponselection_weapondamage: "mortal",
repeating_weaponselection_weaponrange: "100/400m",
repeating_weaponselection_weaponcalibre: "4mm",
repeating_weaponselection_weaponrdf: "10",
repeating_weaponselection_weaponammo: "20",
repeating_weaponselection_weaponheight: "0.7",
repeating_weaponselection_weaponstrenght1hand: "@{weaponweight}/0.2",
repeating_weaponselection_weaponstrenght2hand: "@{weaponweight}/0.7"});
}
else {
console.log("Didn't update anything...");
}
console.log("Finished with doing stuff!");
});
});
</script>
<div>