Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Customer Character Sheet - Repeating Weapons

1746504053

Edited 1746504083
I have a sheet worker that takes the damage dice from a repeating weapon, passes it to another function to parse it from XdY + Z to (X * Y) + Z and sets it so it can be added to damage if the roll is critical or an extreme success.  Works great for all the repeating weapons, but for the base weapon in the repeating weapon section, I can't find a way to pull it's damage dice because it has no Row ID, both just come back as undefined.  Yet everything works fine in the roll template, it's just missing the damage calculation, because it's passing it undefined values which get turned into 0's, so you ( 0 * 0 ) + 0 for the extra damage. Is there a way to access the base or template weapon information or should that row just be not used and only use the repeating weapons themselves, which are working. on("change:repeating_weaponsmdr:weapondamage_mdr", function(eventInfo) {   const repeatingId = eventInfo.sourceAttribute.match(/repeating_weaponsmdr_([^_]+)_/)[1];     getAttrs([`repeating_weaponsmdr_${repeatingId}_weapondamage_mdr`], function(values) {     const damageString = values[`repeating_weaponsmdr_${repeatingId}_weapondamage_mdr`] || "";     const updates = parseDamageString(damageString, `repeating_weaponsmdr_${repeatingId}`);     setAttrs(updates);   }); });
1746504560
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It sounds like you've done something like this for your weapon section? <div class="base-weapon"> <!-- weapon info that is always there --> <input name="attr_weapon_name" type="text"> <input name="attr_weapon_dice" type="text"> </div> <fieldset class="repeating_weapons"> <input name="attr_weapon_name" type="text"> <input name="attr_weapon_dice" type="text"> </fieldset> If that's what you are doing, then I'd just recommend doing away with the static weapon and using only the repeating section for weapons. If you really need to have an empty weapon when a sheet is first created, just create via sheetworker on sheet:opened  if there isn't a weapon already in the section.
Here's what I have <fieldset class="repeating_weaponsmdr"> <div class="flex-row"> <input type="hidden" name="attr_damage_numdice" value="0"> <input type="hidden" name="attr_damage_dicesize" value="0"> <input type="hidden" name="attr_damage_bonus" value="0"> <input type="hidden" name="attr_weaponstrain_mdr" value="0"> <div class="flex-cell weapon-name"><input type="text" name="attr_weaponname_mdr"></div> <div class="flex-cell weapon-roll"> <button type="roll" class="new-roll" name="roll_weaponskill_mdr_check" value="&{template:coc-attack-1} {{name=@{weaponname_mdr}}} {{modifier=[[@{dice_modifier_checkbox} + 0]]}} {{success=[[@{weaponskill_mdr}+@{dice_modifier_checkbox}]]}} {{hard=[[floor((@{weaponskill_mdr}+@{dice_modifier_checkbox})/2)]]}} {{extreme=[[floor((@{weaponskill_mdr}+@{dice_modifier_checkbox})/5)]]}} {{malf=@{weaponmalf_mdr}}} {{roll1=[[1d100]]}} {{damage=[[@{weapondamage_mdr}@{weapondb_mdr}]]}} {{extremedamage=[[(@{damage_numdice}*@{damage_dicesize})+@{damage_bonus}]]}} {{strain=[[ @{weaponstrain_mdr} + 0 ]]}}"></button> </div> <div class="flex-cell weapon-skill"> <select name="attr_weaponskill_mdr"> <option value="@{unarmed_mdr}" data-i18n="unarmed-u">Unarmed</option> <option value="@{archery_mdr}" data-i18n="archery-u">Archery</option> <option value="@{gunnery_mdr}" data-i18n="gunnery-u">Gunnery</option> <option value="@{heavy_weapons_mdr}" data-i18n="heavy_weapons-u">Heavy Weapons</option> <option value="@{melee_weapons_mdr}" data-i18n="melee_weapons-u">Melee Weapons</option> <option value="@{firearms_handgun_mdr}" data-i18n="firearms(hg)-u">Pistol</option> <option value="@{firearms_rifle_mdr}" data-i18n="firearms_rifle-u">Rifle/Shotgun</option> <option value="@{firearms_smg_mdr}" data-i18n="firearms_s_m_g-u">Submachine Gun</option> <option value="@{throw_mdr}" data-i18n="throw-u">Throw</option> <option value="@{magic_universal_mdr}" data-i18n="magic_universal-u">Magic</option> </select> </div> <div class="flex-cell weapon-damage"><input type="text" name="attr_weapondamage_mdr"></div> <div class="flex-cell weapon-damage-bonus"> <select name="attr_weapondb_mdr"> <option value="+0">+0</option> <option value="+round((@{damage_bonus})/2)">+½db</option> <option value="+@{damage_bonus}">+db</option> </select> </div> <div class="flex-cell weapon-range"><input type="text" name="attr_weaponrange_mdr"></div> <div class="flex-cell weapon-attacks"><input type="text" name="attr_weaponattacks_mdr"></div> <div class="flex-cell weapon-ammo"><input type="text" name="attr_weaponammo_mdr"></div> <div class="flex-cell weapon-malf"><input type="text" name="attr_weaponmalf_mdr"></div> <div class="flex-cell weapon-strain"><input type="text" name="attr_weaponstrain_mdr"></div> </div> </fieldset>
Nevermind, I'm a victim of my own testing.  I fired up a new character and the repeating_weaponsmdr doesn't show up, I click add, get the repeating_weaponsmdr (1st added Weapon). It was an artifact left over from testing that I was fighting.  My apologies.
And I can't delete it either, because I'm sure the delete is looking for a row ID to delete. /facepalm
Rooted it out via API script on('chat:message', function(msg) { if (msg.type === 'api' && msg.content === '!clean-bad-weapons') { let characters = findObjs({ _type: 'character' }); characters.forEach(char => { let attrs = findObjs({ _type: 'attribute', _characterid: char.id }); attrs.forEach(attr => { let name = attr.get('name'); if (name.startsWith('repeating_weaponsmdr_undefined')) { log(`Deleting attribute: ${name}`); attr.remove(); } }); }); sendChat('System', '/w gm Cleaned up bad repeating weapon entries.'); } }); "##########> Sandbox [DEFAULT 2025-04-18] : Ready fired after 1.34s, 23 objects." "Deleting attribute: repeating_weaponsmdr_undefined_weapondamage_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponname_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponskill_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponstrain_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponrange_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponattacks_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponammo_mdr" "Deleting attribute: repeating_weaponsmdr_undefined_weaponmalf_mdr"