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 .
×
We are currently investigating server problems that may lead to lag or loading errors on the platform.

Sheet worker not responding to change

Hey guys, I know this issue is brought up a lot and it usually turns out to be a typo or some bad syntax but I just can't figure out where I went wrong. To make my issue as simple as possible, I've cut out everything but this: <script type="text/worker">     on("change:hp", function() {      console.log("DING!");     }); </script> <input type="text" name="attr_hp"> When I change the text field, nothing appears in the browser console. Could anyone give me some advice? Thanks!
1576273527
GiGs
Pro
Sheet Author
API Scripter
Have you tried exactly that worker, or did you just cut it down for posting to the forums? That should work. Do you have more than one script block in your html? It's normal to put your script block at the very beginning or (more often) very end. In the past, they have been issues with having more than one script block, but i dont think that is a problem now. Can you post some code you've tried that does something on your character sheet? Not the trimmed down version. Let's get to the root of the issue.
It's the exact code I was running. Nothing more. The only code I was using prior to trimming was some lazy HTML and CSS for some stats in columns, which didn't have any other script blocks. I've also tried it in both Chrome and Edge, neither are getting the log message. The only thing that  So, I figured out what it was. I was testing it with the preview window in Game Settings. The script only seems to execute in an actual roll20 session. Is that by design? I can't say I recall reading that in the docs.
1576294397
Victor B.
Pro
Sheet Author
API Scripter
Preview?  I've never even heard of preview.  Always test in Roll20 on an actual char sheet in a real session if using sheet workers or making any other changes.  Create a new game if necessary.  Sheet workers are tricky at best.  GiGs is a master of them.  I am not.  
1576299060
Kraynic
Pro
Sheet Author
The preview window will show you the html and css fairly accurately.  It doesn't utilize scripts though.  You have to be in game, so the usual testing method is to have one tab on the settings and one with the live game.  Any save you make, you refresh the game and see how it works.
Fair enough. It would be nice if the preview actually could utilize the scripts, but I guess it's not something that can be done easily. In any case, I think it's worth pointing out in the character sheet dev documentation, which I can't say I saw anywhere.
1576339370
Kraynic
Pro
Sheet Author
If you think you have a good way to phrase it, edit it in.  At this point, it does tell you the preview is to show you how the sheet will look, but doesn't specifically tell you that is all it does.  The preview is pretty limited, since it won't show you more than one line of a repeating section (because it doesn't show the add/modify buttons).
Something that works for me is to open two browser instances, one with the game, and the other with the character sheet editor. As I save changes to the character sheet, I hit the refresh button in the game browser window and test the sheet. Then I pop back over to the editor window and make more changes (or fix my mistakes). This works really well if you have two monitors.
I made an edit, though I'm not sure if it could be worded better. <a href="https://wiki.roll20.net/Building_Character_Sheets#Preview_Panel" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Preview_Panel</a> As an aside, it would be nice to have a cleaner workflow for developing sheets, but I will use the method Rabulias has suggested. Thanks!