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

Simple question about sheet workers, buttons and console log:

1746298140

Edited 1746298188
Okay everyone, I am an experienced web dev and I've been trying to put together a "/roll" builder for a text box but I can't even get the simplest of things to work. <!--Sheet Workers --> <script type="text/worker">     on('sheet:opened', function(){       console.log("Sheet Opened!");     });     on("clicked:activate", function() {       console.log("Activate button clicked!");     });      </script> <div class=containerRoller>     <div>         <button type="action" name="act_activate">Activate!</button>         <button class="reset" type="action" name="act_reset" data-i18n-title="reset-all" title="">reset</button>     </div> </div> I can't even get these two scripts to fire, either on button click or sheet open to output something to the console log, what am I missing? Ultimately, I am looking to create a sheet that has buttons for dice, that add dice to a poll in which you can then roll that pool.  This is for Cortex Prime. So if I hit a D8 in one column, then a d10 in another column and then a d6 for a third column, a text field would read  /roll d8+d10+d6 Then you hit the roll button and it rolls the pool.
1746300868

Edited 1746305414
GiGs
Pro
Sheet Author
API Scripter
That looks perfectly formed to me. Maybe change the div name, or dispense with the divs altogether for this test. You might want to create a new character, or even an entire campaign, just to see if there's a problem with either. It's normal practice to put the script block at the end of the HTML file, but that shouldn't make a difference.
1746307070
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Running your code in a test game of mine works fine. I know you are an experienced dev, but are you perhaps just missing the logs in among the large amount of warnings and logs that a normal R20 game fires?
Scott C. I clear the log and then hit the buttons an nothing. Tried creating a new campaign and then copied everything over without the divs -- still nothing. I have a pro account, not sure what I am missing.
1746329928
GiGs
Pro
Sheet Author
API Scripter
It sounds like the problem is one that can only be fixed by roll20 devs - it should be working. I'd contact them and ask for help.
1746331849
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Is that the only code you have running in your game? Or is it part of a larger sheet? This sounds to me like there is a syntax error somewhere in your code that is stopping the listeners from actually registering.
1746368251
vÍnce
Pro
Sheet Author
As a test, I would remove all code except for your code posted above.  Also just to be clear, your are checking the console from the browser's Dev Tools  in FF or Chrome and not the API console, correct? (seen this confusion the past...)
1746379654

Edited 1746379843
I've stripped the code down to just this: &lt;button type="action" name="act_activate"&gt;Activate!&lt;/button&gt; &lt;!--Sheet Workers --&gt; &lt;script type="text/worker"&gt; &nbsp;&nbsp;&nbsp; on("clicked:activate", function() { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log("Activate button clicked!"); &nbsp;&nbsp;&nbsp; }); &lt;/script&gt; And check this imgur link for screenshots of my console in FIREFOX &amp; CHROME. <a href="https://imgur.com/a/btzHRwL" rel="nofollow">https://imgur.com/a/btzHRwL</a>
Believe me, there is no confusion.
1746380662

Edited 1746380756
I was gonna create a new account and see if there's something fubar-ed at the account level, but then I'd have to pay for the new accounts Pro level.
1746382900
vÍnce
Pro
Sheet Author
So... you are showing the preview tab in your screen shot.&nbsp; Do you experience the same "no log" issue in-game?&nbsp; The preview tab SHOULD NOT be used for anything.&nbsp; Honest.&nbsp; It's been notoriously problematic in the past, not to mention that I don't believe sheetworkers actually work outside of an actual game.
vÍnce said: So... you are showing the preview tab in your screen shot.&nbsp; Do you experience the same "no log" issue in-game?&nbsp; The preview tab SHOULD NOT be used for anything.&nbsp; Honest.&nbsp; It's been notoriously problematic in the past, not to mention that I don't believe sheetworkers actually work outside of an actual game. My god, that's more than a bit problematic.&nbsp; Did I miss where it says in the preview window that sheetworkers don't work?
1746384411
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It's #2 on the common mistakes list . Also, using the custom sheet game to develop a sheet is asking for heartache. Using the sheet sandbox is much easier and even allows you to automate code upload via the chrome extension I built .
Scott C. said: It's #2 on the common mistakes list . Also, using the custom sheet game to develop a sheet is asking for heartache. Using the sheet sandbox is much easier and even allows you to automate code upload via the chrome extension I built . Awesome thanks everyone. Issue is solved, just gonna build the sheet in a second window and so on.