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

Looking for help with text/worker

So, I want to create a table, a few of them actually, but I'm not sure how to do it, especially since it involves needing to pull numbers from specific repeating fields like "repeating_provinces_$3_ as opposed to "repeating_provinces_$4_ and so on. I need it to basically do this. <button value="[[defined]]" var defined { if ['stat-number'] and ['other-number'] use XdY } { else if ['stat-number2'] and [other-number2'] use XdY } .................. and so on. Is this possible and if so, how do I do it?
1491366035
Lithl
Pro
Sheet Author
API Scripter
Set the value of the button to some attribute. Create a sheet worker script which triggers on open and whenever one of the dependent attributes changes. Set the attribute being used by the button in the sheet worker. Example: <button name="roll_example-roll" value="@{example-roll-value}"></button> <input type="number" name="attr_example-input"> <script type="text/worker"> on('sheet:opened change:example-input', function() { getAttrs(['example-input'], function(values) { setAttrs({'example-roll-value': parseInt(values['example-input']) + 5}); }); }); </script>
Still learning js, so I'll have to play with it to see how it works, but thank you for the head-start :D This gives me a lot to learn from.