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

How to get RowID on clicked trigger of a button

1649158959

Edited 1649159011
Hi, I try to get a field inside a repeatable_section (which i have multiple, hence the "-archery" at the end of the fieldset class name) where the button i click into is also. on ( 'clicked:charmcast' , TAS . _fn ( function clickCharmCast ( e ) {     TAS . debug ( 'ON click:charmcast e=' , e );     let attrName = ` ${ e . htmlAttributes [ 'data-section' ] } _charm-name` ;     TAS . debug ( `attrName= ${ attrName } ` );     getAttrs ([ attrName ], values => {         TAS . debug ( 'values=' , values );         TAS . debug ( `rollexpr=' ${ values [ attrName ] } '` );     }); })); and in HTML i have < fieldset class = "repeating_charms-archery" > containing < input type = "text" name = "attr_charm-name" > and < button type = "action" name = "act_charmcast" data-section = "repeating_charms-archery" > Can someone tell me what i'm doing wrong ? Wiki tells that it i do a getAttr inside a trigger that is inside a repeatable section, it scope and works, as i've read, else, how can i get the RowID ? it's the other only way i could access this variable but i can't find how to include it in my html so i can use it in the sheetworker Thanks everyone for your helpsm and have a great day !
1649160664

Edited 1649160694
GiGs
Pro
Sheet Author
API Scripter
I don't use TAS so I cant tell you if there's something wrong with your syntax there. Luckily it's not the only way to get a rowID. I'm also not familiar with data-section tag you have in the button. What is it? Something related to javascript that isn't supported on roll20? On to my question: What do you want the rowID for? It's possible you don't need it. If you are calling an attribute from the same row of a repeating section, you just need to use, say @{repeating_charms-archery_charm-name} and roll20 will insert the row id automatically. If you do need the repeating section's row id, here's a sheet worker that breaks one process of getting it and building up your attr_name, into steps. You can easily combine or dispense with some steps depending on what you actually need:      on ( 'clicked:repeating_ charms-archery :charmcast' , function ( e ) {         const button_name = e . sourceAttribute ;         const bits = button_name . split ( '_' ); // break the repeating section name into segments         const section = `repeating_ ${ bits [ 1 ] } ` ;         const id = bits [ 2 ]; // if you just want the id, you can use e . sourceAttribute .split('_')[2];         const attr_name = ` ${ section } _ ${ id } __charm-name` ;         console . log ( attr_name );             });
1649162291

Edited 1649162692
it's my way to include the name of the repeating section so i can try to find the variable with javascript, and i don't think there is any TAS problem, i just use it for debug clarity in console there ah ok i think i understand my problem, i'm not binding on the button of a specific repeating section with my method, but with yours i have to do each of my repeating section, that's what i was trying to avoid ok i'll do a little bit of js to not c/c everything, only need to make an array of all my charm "pages" (there is a lot T_T) and that should work, thanks ! do you know how to do the same kind of mechanic through the jquery that roll20 gave us ? actually, i'm using a button type="roll" to throw a template, and as i needed extended roll features, i used my own api script to do rolls, and actually i changed the binding to : $20 ( 'button.default-whisper' ). on ( 'click' , TAS . _fn ( function clickDefaultCharmCast ( e ) { anyway, the real goal is to cast the roll if needed, which can be entered in an input type="text", ... but i just discovered, sheetworker cant send to chat ... so i think i'll have to use sheetworker to hide/display other buttons that cast 2 things or 1 depending if text for the script is valid T_T
1649163352
GiGs
Pro
Sheet Author
API Scripter
sheet workers can send to chat, kind of, if you hijack the new custom roll parsing system, but it's not exactly user-friendly. But if you are using your own script, I'm not sure of the details so can't really help. Also, I havent explored roll20's jQuery yet, so don't know much about that. That said, if you want to use this method with multiple sheet workers, you can do a forEach loop, like     const sections = [ 'charms-archery' , /* put your other section names here */ ];     sections . forEach ( section => {         on ( `clicked:repeating_ ${ section } :charmcast` , function ( e ) {             const button_name = e . sourceAttribute ;             const id = button_name . split ( '_' ). bits [ 2 ]; // if you just want the id, you can use e.sourceAttribute.split('_')[2];             const attr_name = `repeating_ ${ section } _ ${ id } __charm-name` ;             console . log ( attr_name );         });     });
1649164403

Edited 1649164422
yeah that's exactly what i was thinking of can you elaborate or include links/example of the new custom roll parsing system ? could you send only text ? or a "macro" or "script", like a !setattr --name John --HP|17|27 --Dex|10 ? thanks for your time and help !
1649165225
GiGs
Pro
Sheet Author
API Scripter
Its complex - you can send anything you can send as part of a roll output, which can be basic text or an actual roll. I've never tried to send script text. In principle it seems like it should work, but roll20 may have set some safeguards against that (because the chat would be responding to the roll for custom roll parsing, and the script simultaneously, and they could conflict with each other). I'm too tired to post anything right now - it would help to know exactly what output you are sending to chat, and what you need from it. The wiki has a page on custom roll parsing: <a href="https://wiki.roll20.net/Custom_Roll_Parsing" rel="nofollow">https://wiki.roll20.net/Custom_Roll_Parsing</a>
well, im sending the "normal" template i used previously, and i want to include the text as is and send it, i made it work with a button type="roll" value="TEMPLATE1\n@{charm-rollexpr}" and i use this text box in every charm &lt; input type = "text" name = "attr_charm-rollexpr" style = " width: 99% " placeholder = "!exr 15# -d 8,9 -r 6 -v" /&gt; but it could be less html uselessness if i could do it with the way you describe, i'll see later, it's kind of late here too x)