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

[Sheet Worker] Tutorial?

1508242620
Axel
Pro
Sheet Author
I would very much like to find a full tutorial for how to use sheet workers, because the wiki doesn't really help me sufficiently as a novice, and searching the forums hasn't been too instructive either, since most posts I've found are about specific use questions. Is there a full primer anywhere on how to use sheet workers and their syntax? It doesn't look quite like I'm expecting JavaScript to look, but then it's been far too long since I learned or used any scripting language, so i need some basics.
1508253504

Edited 1508253552
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Sheetworkers are just javascript, except without any access to the DOM. The only way for your sheetworker script to interact with the VTT is through the functions detailed in the wiki (all of which,except for generateRowID, are asynchronous). I'd recommend looking up some javascript tutorials online and pulling the code for some sheetworker driven character sheets from the github repository. You may have to contact sheet authors to get non-minified code. There are a few additions to the "just javascript" though: The sheetworkers also have access to the  underscore.js library The Promise and async/await syntax from ES6 and ES7 respectively does not work with sheetworkers as it breaks the relationship between the running code and the specific character sheet it should be interacting with. A suggestion: I would recommend keeping your number of getAttrs and setAttrs to a minimum for any given operation. Making long chains of these can cause performance issues with the sheet. I am pretty new to the whole sheet creation scene, so I'm sure others will have better/different advice. Scott EDIT: Also, the sheetworkers, like API scripts, are event driven. This may be part of the cause of the disconnect you are experiencing.