Advertisement Create a free account

[Sheet Worker] Can you use "on clicked:" for a button in a repeating area?

1547230588
And if so, how?  This doesn't work: <fieldset class="repeater">     ...     <input type=button name=act_my-button>     ... </fieldset> on ("clicked:repeater:my-button", function(eventInfo) {     ... }) The event handler never gets triggered.  If it matters, the button is also triggering a rolltemplate.- and that works. What I need to do is change some attributes (all within the context of the single repeating row) as a consequence of the button being hit.  Specifically, the button generates a ranged weapon attack roll, and I'm trying to decrease the loaded ammunition in the weapon when it is fired. All suggestions welcome!
1547241191

Edited 1547241248
Scott C.
Pro
Sheet Author
API Scripter
In a specific situation, it is possible to use the on:clicked  event listener. First though, there's a misconception in your code above. Buttons are not input elements, they are their own html element: <input type=button name=act_my-button> should be <button type='action' name='act_my-button'>Button Text</button> or <button type='roll' name='roll_my-button' value='what you want sent to chat'>Button Text</button> Both of these buttons are valid on character sheets, but have different effects. The action button can be clicked for an effect to take place (and you would use on:clicked  to listen for that click). The roll button sends a macro to chat and clicking it does not create an event for on:clicked  to listen for. So, if you're using an action button, then yes you can listen for the click. Additionally, I might recommend some changes to your proto sheetworker: on ("clicked:repeater:my-button", function(eventInfo) {     ... }) This is technically correct, but unless you are planning on having buttons with the same name in multiple repeating sections, you could simply change this to: on ("clicked:my-button", function(eventInfo) {     ... }) Hope that all helps, Scott
1547244423
The <input type="button"> vs <button...> was just carelessness.  (I was stripping down my code to siimplify the example and got a bit carried away.) So, the short answer is... I can have a button that EITHER triggers a sheet worker OR triggers a roll template.   I sorta expected that.  So the next question becomes... can I have the sheetworker trigger the roll? (Oh, and thx for the simplifer on the "clicked:"  Does that apply to on("changed:repeating-attrib... as well?)
1547251513

Edited 1547251659
Scott C.
Pro
Sheet Author
API Scripter
Bob O. said: So, the short answer is... I can have a button that EITHER triggers a sheet worker OR triggers a roll template.   I sorta expected that.  So the next question becomes... can I have the sheetworker trigger the roll? Short answer is no. The slightly longer answer is that you might be able to accomplish this whenever charactermancer functions go live for the community sheet authors  Edit:as for the change event,see the wiki for full details: https://wiki.roll20.net/Sheet_Worker_Scripts#change:.3Cattribute_name.3E