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

Events are not captured in script workers.

Argh.   As per the title.  I can't even see the action in the console (see comments in the code).  Any idea what I am doing wrong here? Button: <button type="action" name="act_test" class="button-roll">Percep</button> Script Worker: <script type="text/worker"> on('clicked:test', (event) => { console.log("In Clicked Test"); //this does not get logged         console.log(event); //this does not get logged testRoll(); //this does not fire }); const testRoll = () => { let rollExpression = '1d100!>95'; //+ @{perception} +?{Other bonus/penalty?|0} // + @{skill_bonus}[Bonus] + @{skill_mod}[Mod]'; // Wrap the two @{attributes} in a [[subroll]] if they're taking up too much space let rollBase = '&{template:test} {{name=Test}} {{roll1=[[${rollExpression}]]}} {{downroll=[[0]]}} {{roll1name=${rollExpression}}} {{roll1mod=- [[1d100!>95]]}} {{roll1final=[[0]]}}'; startRoll(rollbase, (results) => { let downRoll = results.roll1mod.result; let origRoll = results.roll1.result; let dieRoll = results.roll1.dice[0]; let rollData = {}; // Holding the computed data in an object is a bit cleaner if your rolls get more complex if (dieRoll < 6) { rollData.downroll = 1; // This tells the roll template to display the mod & final sections rollData.roll1final = origRoll - downRoll } finishRoll(results.rollId, rollData); }); } //Other scripts go here </script> Any idea on what I may have done (or not done)? I have even stripped out the other scripts, and still no love.  Could it be an unclosed tag in the HTML? I am not sure how to even debug this.  Do I need to remove all the HTML as well and see if just the button and the script works?
1628785421

Edited 1628785476
vÍnce
Pro
Sheet Author
Not sure if it applies... but maybe post your html/css for the action button as well as it's parent element.&nbsp; I recall there was/is a strange bug that can cause an action button to not trigger an event. ( <a href="https://app.roll20.net/forum/permalink/7330244/" rel="nofollow">https://app.roll20.net/forum/permalink/7330244/</a> )
1628786177
GiGs
Pro
Sheet Author
API Scripter
Is the action button in a repeating section?
1628788394
Andreas J.
Forum Champion
Sheet Author
Translator
vÍnce said: I recall there was/is a strange bug that can cause an action button to not trigger an event. ( <a href="https://app.roll20.net/forum/permalink/7330244/" rel="nofollow">https://app.roll20.net/forum/permalink/7330244/</a> ) Button name's containing an underscore e.g "attack_roll"&nbsp; inside a repeating section, ARE NOT DETECTED by the&nbsp;on("clicked:&nbsp;listener. Ugh, one more of these "use/don't use underscore" in specific names related to rep sections. I added mention of this to the BCS/Bugs page.
1628789435

Edited 1628789451
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
In addition to the things to check that have already been mentioned, which I'm pretty sure it's going to be. Are you sure that there isn't an error in your scripts elsewhere that would prevent the whole script from being parsed. Something like a syntaxerror/typeerror that causes the script to fail on boot.
GiGs said: Is the action button in a repeating section? It is not, but it is in a div that you can hide / show. vÍnce said: Not sure if it applies... but maybe post your html/css for the action button as well as it's parent element.&nbsp; I recall there was/is a strange bug that can cause an action button to not trigger an event. ( <a href="https://app.roll20.net/forum/permalink/7330244/" rel="nofollow">https://app.roll20.net/forum/permalink/7330244/</a> ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class="pc-skillawareness"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class="table-row"&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data-skills-name"&gt;&lt;span&nbsp;data-i18n="perception"&gt;Perception&lt;/span&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perception"&nbsp;title="perception"&nbsp;value="0"&nbsp;readonly&nbsp;/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills-wide"&nbsp;name="attr_perceptionranks"&nbsp;title="perceptionranks&nbsp;(Number&nbsp;of&nbsp;Ranks)"&nbsp;value="0"/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perceptionrankbonus"&nbsp;title="perceptionrankbonus&nbsp;(Skill&nbsp;Rank&nbsp;Bonus)"&nbsp;value="-25"&nbsp;/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data-skills"&nbsp;style="width:&nbsp;20px;"&gt;&nbsp;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data-skills-stats"&gt;&lt;b&gt;&lt;span&nbsp;data-i18n="agility-a"&gt;Ag&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perceptionstat"&nbsp;title="perceptionstat&nbsp;(Stat&nbsp;Bonus)"&nbsp;value="0"&nbsp;&nbsp;/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perceptionknackbonus"&nbsp;title="perceptionknackbonus&nbsp;(Knack&nbsp;Bonus)"&nbsp;value="0"&nbsp;&nbsp;/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type="checkbox" name="attr_perceptionisprof" value="0" &gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perceptionspecialmod"&nbsp;title="perceptionspecialmod&nbsp;(Any&nbsp;Special&nbsp;bonuses)"&nbsp;value="0"/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perceptionitemmod"&nbsp;title="perceptionitemmod&nbsp;(Item Bonus)"&nbsp;value="0"/&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;textarea&nbsp;rows="1"&nbsp;cols="50"&nbsp;class="table-data-skills-notes"&nbsp;name="attr_perceptionnotes"&nbsp;title="perceptionnotes"&gt;&lt;/textarea&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;textarea&nbsp;rows="1"&nbsp;cols="50"&nbsp;class="table-data-skills-macrobox"&nbsp;name="attr_perceptionmacro"&nbsp;title="perceptionmacro"&gt;/w&nbsp;gm&nbsp;&amp;{template:RmuStdRoll}&nbsp;{{skillflag=true}}&nbsp;{{name=@{character_name}'s&nbsp;Perception-@{perceptionname}}}&nbsp;{{subtags=Category:&nbsp;Artistic,&nbsp;Active}}&nbsp;{{check= Perception&nbsp; (@{perceptionranks}&nbsp;ranks):&nbsp;}}&nbsp; {{checkroll=[[1d100!&gt;@{oeuproll}cf&lt;@{oedownroll}cs=100&nbsp;+[[@{perception}]]&nbsp;+?{Other&nbsp;bonus/penalty?|0}&nbsp;]]}}&nbsp;{{oedownroll=&nbsp;-[[1d100!&gt;@{oeuproll}[open&nbsp;ended&nbsp;down&nbsp;roll;&nbsp;subtract&nbsp;from&nbsp;previous&nbsp;roll]&nbsp;]]}}&nbsp;{{critroll=&nbsp;**Check&nbsp;for&nbsp;Nat&nbsp;100!!!!**}}&nbsp;{{highlight66=&nbsp;[[66&nbsp;+?{Other&nbsp;bonus/penalty?|0}&nbsp;+@{perception}&nbsp;]]}}&nbsp;{{highlight66roll=**Natural&nbsp;66.**&nbsp;}}&nbsp;{{notes=@{perceptionnotes}&nbsp;}}&nbsp;&lt;/textarea&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data"&gt;&lt;button&nbsp;type="action"&nbsp;name="act_test" class="button-roll"&gt;Pcptn&lt;/button&gt;&lt;/span&gt;&nbsp;&lt;!--title="perceptioncheck"&nbsp;value="perception"&gt;Percep&lt;/button&gt;&lt;/span--&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;span&nbsp;class="table-data-skills-sm"&gt;&lt;button&nbsp;type="roll"&nbsp;class="button-roll"&nbsp;name="roll_test"&nbsp;title="perceptioncheck"&nbsp;value="@{perceptionmacro}"&gt;&lt;/button&gt;&lt;/span&gt; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/div&gt; &lt;/div&gt;
1628794719

Edited 1628798690
Pantsworth
Sheet Author
So - it has to do with one of the many scripts I have.&nbsp; Removing all the other scripts fixed it.&nbsp; Gonna start putting the other stuff back in and see if I can find the bad code.
1628795386
GiGs
Pro
Sheet Author
API Scripter
I'm not sure why the divs would affect it, but I notice you have a lot of unnecessary HTML tags. First you have a div nested inside a didv each with different classes. There are some cases its necessary to do that, but most often you can just do &lt;div class="pc-skillawareness table-row"&gt; Likewise all those spans, can be simplified For example this &lt;span&nbsp;class="table-data"&gt;&lt;input&nbsp;type="text"&nbsp;class="table-data-skills"&nbsp;name="attr_perception"&nbsp;title="perception"&nbsp;value="0"&nbsp;readonly&nbsp;/&gt;&lt;/span&gt; could be &lt;input&nbsp;type="text"&nbsp;class="table-data table-data-skills"&nbsp;name="attr_perception"&nbsp;title="perception"&nbsp;value="0"&nbsp;readonly&nbsp;&gt; and just make sure your css targets the input not the span, if you use span.table-data. This is the one that jumped out at me and made me notice this: &lt;span&nbsp;class="table-data-skills-stats"&gt;&lt;b&gt;&lt;span&nbsp;data-i18n="agility-a"&gt;Ag&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; That could easily be &lt;span&nbsp;class="table-data-skills-stats bold" data-i18n="agility-a"&gt;Ag&lt;/span&gt; with the addition of a CSS class like .charsheet span.bold { &nbsp;&nbsp;&nbsp; font-weight: bold; } You can include multiple cases in the same tag, and can usually apply any class to any tag, so ofte you don't need to use span or divs as containers, just put the class directly on the input or textbox or whatever.
1628798842

Edited 1629123394
Pantsworth
Sheet Author
That is gold GiGs.&nbsp; Thanks for the input.&nbsp; BTW: Some of these extra spans are use to hide/show skill categories and cannot be removed without changing how the sheet functions