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 .
×

Can I log values somehow?

I tried using console.log("variable value: " + variable) in my sheet worker script (inside a change event handler) - but in the log, I can not seem to find this entry anywhere. The log entries for the change event beeing triggered are there, but my custom logs are not. Does console.log simply not work with roll20 sheet worker scripts? If so, can I do anything else to log some values in the script? I could feed them into a debug input field via setAttrs() but that seems overly complicated.
1493396429

Edited 1493581253
PaprikaCC
API Scripter
I haven't worked with character sheets yet, but I do know that the roll20 equivalent to console.log() is just log(). Its output goes to the API Script page in your game.
1493398960

Edited 1493399026
Lithl
Pro
Sheet Author
API Scripter
PaprikaCC said: I haven't worked with character sheets yet, but I do know that the roll20 equivalent to console.log() is just log(). Its output goes to the API Script page in your game. That's for API scripts, which run on an API server, and don't have access to the console object. For sheet worker scripts, you indeed use console.log, and the output will be in the bowerser's  console log (Ctrl+Shift+J or F12 in Chrome), not Roll20's API log. Of course, Roll20 is spitting a lot of other information into the browser's log (which is used to help debug problems people have), so it can sometimes be difficult to find your own log line.
Thank you, yes, I tried log() but as Brian said, it does not work... But console.log does not work for me either, interestingly enough. I'll take another look at my code and maybe post that here later.
1493458332
Finderski
Pro
Sheet Author
Compendium Curator
Usually, when console.log doesn't work for me, it means there's a problem with my javascript.  Once you find that error and correct it, it should show up.
Yea, that was the problem... I was using elseif instead of else if .... And thus the logs did not show up. Seems like Roll20 just silently "throws away" the worker, and because of that neither the error showed up in the console and neither did the console.logs (which where before the line that had the error) Thank you, I got it to work with that.
1493489773
Lithl
Pro
Sheet Author
API Scripter
Patrick said: Seems like Roll20 just silently "throws away" the worker, and because of that neither the error showed up in the console and neither did the console.logs (which where before the line that had the error) Yeah, it's unfortunate. You can pin down  whether  you have a fatal error by if the log doesn't  contain "Starting up WEB WORKER", and when you do things to the character sheet, you should also get lines like "Triggering for sheet:opened", "Triggering for change: some-attribute ", etc.