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

Trying to make an Equip button

On this sheet is a Tab called Inventory. In this Tab is two more separate tabs, Equipment and Storage. In the storage tab, I have a fieldset class="repeating_storage". This stores all the info for different types of items. Every item has a name, type, description, and characteristics about it (as shown in code block 1; this is just for weapons in this block, all items are very similar).  In the Equipment tab is a picker (code block 2) that uses the same fieldset class as I am trying to pull items from that last. When trying to click the equip button, nothing seems to happen. The equip is the bottom of a sheetworker that up until this point in the worker, it works. The rest of the worker is tied to opening and displaying what is in the picker. Can somebody explain why my equip button doesn't seem to fire? I have done multiple debugs of putting console.log, setAttr on debug labeled attributes. Nothing shows in Inspect element dev console or in the Attributes & Abilities for debugging. ``` <!-- Weapon -->               < div class = "type-block type-weapon" >                 < div class = "row" >                   < label class = "col-left"                     > Damage < input type = "number" name = "attr_wep_damage"                   /></ label >                   < label class = "col-mid"                     > Armor Pen. < input type = "number" name = "attr_wep_pen"                   /></ label >                   < label class = "col-right title-label"                     > Proficiency Stat                     < select name = "attr_wep_profstat" >                       < option value = "" > — choose — </ option >                       < option value = "STR" > STR </ option >                       < option value = "VIT" > VIT </ option >                       < option value = "AGI" > AGI </ option >                       < option value = "INT" > INT </ option >                       < option value = "PER" > PER </ option >                     </ select >                   </ label >                   <!-- computed, read-only chip text like “PER 10” -->                   < input type = "hidden" name = "attr_wep_profchip" />                 </ div >                 < div class = "row" >                   <!-- WEAPON: Type + Hands -->                   < div class = "col-left wep-type-stack" >                     < label class = "title-label"                       > Weapon Type                       < select name = "attr_wep_class" >                         < option value = "" > — choose — </ option >                         < option value = "melee" > Melee </ option >                         < option value = "ranged" > Ranged </ option >                         < option value = "magic" > Magic </ option >                         < option value = "shield" > Shield </ option >                       </ select >                     </ label >                     <!-- visibility flag controlled by the worker -->                     < input type = "hidden" name = "attr_wep_showhands" value = "0" />                     < label class = "wep-hands title-label"                       > Hands                       < select name = "attr_wep_hands" >                         < option value = "" > — </ option >                         < option value = "1h" > One-handed </ option >                         < option value = "2h" > Two-handed </ option >                       </ select >                     </ label >                   </ div >                   <!-- display-only chip for the summary -->                   < input type = "hidden" name = "attr_wep_typechip" />                   < label class = "col-mid"                     > Crit Multiplier < input                       type = "number"                       name = "attr_wep_dmgmult"                       value = ""                       step = "0.01"                       min = "0"                       inputmode = "decimal"                   /></ label >                   < label class = "col-right grow"                     > Extra Multipliers & Effects                     < input type = "text" name = "attr_wep_extra" />                   </ label >                 </ div >               </ div > ``` ``` < div class = "picker-list" >               < fieldset class = "repeating_storage" >                 <!-- STATE (per row) -->                 < input type = "hidden" name = "attr_picker_visible" value = "0" />                 < input type = "hidden" name = "attr_item_name_lc" value = "" />                 < input type = "hidden" name = "attr_picker_match" value = "1" />                 <!-- ROW -->                 < div class = "picker-row" >                   < div class = "picker-card" >                     < div class = "picker-name" >                       < span name = "attr_item_name" ></ span >                     </ div >                     < div class = "picker-meta" >                       < span name = "attr_item_type" ></ span >                       < span name = "attr_wep_class" ></ span >                       < span name = "attr_arm_class" ></ span >                       < span name = "attr_acc_class" ></ span >                     </ div >                     < button                       type = "action"                       name = "act_pick_for_equip"                       class = "btn small"                     >                       Equip this                     </ button >                   </ div >                 </ div >               </ fieldset >             </ div > ``` ```   /* ===== Equip selected row (works whether inside or outside repeater) ===== */   on ( 'clicked:repeating_storage:pick_for_equip' , function ( e ){ handleEquipClick ( e ); });   function handleEquipClick ( e ){     var id = rowId (( e && e . sourceAttribute ) || '' );     if ( ! id ) {       setAttrs ({ __equip_evt: 'no-rowid' , __equip_src: ( e && e . sourceAttribute ) || '' , __equip_time: String ( Date . now ()) }, { silent: true});     } else {       getAttrs ( [ 'picker_slot' , RS ( id , 'item_name' ) ] , function ( v ){         var slot = normSlot ( v . picker_slot );         var name = v [ RS ( id , 'item_name' ) ] || '' ;         var out   = {};         if ( slot === 'weapon' ) { out . eq_weapon = name ; out . eq_weapon_id = id ; }         else if ( slot === 'offhand' ) { out . eq_offhand = name ; out . eq_offhand_id = id ; }         else if ( slot === 'helmet' ) { out . eq_helmet = name ; out . eq_helmet_id = id ; }         else if ( slot === 'chestpiece' ) { out . eq_chest = name ; out . eq_chest_id = id ; }         else if ( slot === 'gloves' ) { out . eq_gloves = name ; out . eq_gloves_id = id ; }         else if ( slot === 'legs' ) { out . eq_legs = name ; out . eq_legs_id = id ; }         else if ( slot === 'boots' ) { out . eq_boots = name ; out . eq_boots_id = id ; }         else if ( slot === 'earring' ) { out . eq_earring = name ; out . eq_earring_id = id ; }         else if ( slot === 'necklace' ) { out . eq_necklace = name ; out . eq_necklace_id = id ; }         else if ( slot === 'bracelet' ) { out . eq_bracelet = name ; out . eq_bracelet_id = id ; }         else if ( slot === 'ring1' ) { out . eq_ring1 = name ; out . eq_ring1_id = id ; }         else if ( slot === 'ring2' ) { out . eq_ring2 = name ; out . eq_ring2_id = id ; }         else {           setAttrs ({ __equip_evt: 'unknown-slot:' + slot , __equip_row: id , __equip_time: String ( Date . now ()) }, { silent: true});           return ;         }         out . eq_ping = String ( Date . now ());         setAttrs ( out , { silent: true}, closePicker ); // close after equipping       });     }   } ```
1755639961

Edited 1755640186
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
with the code that you posted, the problem is that there is no input for a user to enter something in and make the row "real". Until it is real with some sort of data stored in it (either by user input or programmatic sheetworker creation), the buttons are not hooked up. Also, the forums are not markdown capable unfortunately. To post a code block, use the wand button at the top left of the message editor. Actually, there is something else going on. Not sure what yet though.
1755640472

Edited 1755640542
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah! Missed that you were using underscores in your action button name. There is a long standing bug that causes action buttons with underscores in their names to not work when in repeating sections. Change your action button name to pick-for-equip and it will work.
This block later underneath the Weapon block ties to closing my editor to "make the item real" < div class = "editor-footer" > < button type = "action" name = "act_done" class = "btn done" > Done </ button > </ div > This block is the finalize to close the editor and paste our card. < script type = "text/worker" >   /* Storage: Done → finalize (collapse editor, show card) */   const rowPrefixFrom = ( sa ) => {     const m = ( sa || "" ). match ( / ^ (repeating_[^_] + _[^_] + _) / );     return m ? m [ 1 ] : null; // e.g. "repeating_storage_-ROWID_"   };   on ( "clicked:repeating_storage:done" , ( e ) => {     const pfx = rowPrefixFrom ( e . sourceAttribute );     if ( ! pfx ) return ;     const upd = {};     upd [ ` ${ pfx } item_finalized` ] = "1" ;     setAttrs ( upd );   }); </ script >
Ignore my second block then. Preciate that.