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

Problems to get Sheet Worker to work

Hi folks, I'm currently working on a custom sheet for my group but I cant't get the sheet worker to run. I searched already in the wiki and other forum post, but the examples presented there won't work either for me. The last example is reduced to just one displayed attribute line for testing. Currently the code looks like the one below and in the css section is some stuff. Also tried to put this in the api section, but with no success. Can anyone tell me what I do wrong? Did I overread something? <div class="sheet-overall-wrapper">     <table class="sheet-SM-data-table">         <tr>             <th colspan=2>Attribute</th>             <th width="6%">Start</th>             <th width="6%">Value</th>             <th width="6%">mod</th>         </tr>         <tr>             <td>Mystik</td>             <td>MYS</td>             <td><input type="number" name="attr_MYSTIK_Start" value="0" /></td>             <td class="sheet-SM-highlightedField"><input type="number" name="attr_MYSTIK" value="0" /></td>             <td><input type="number" name="attr_MYSTIK_mod" value="0" /></td>         </tr>     </table>          </div> <!-- Scrips  --> <script type="text/worker"> on("change:mystik_start", function() {          sendChat("Test Modul", " MYS changed!");          getAttrs(["MYSTIK_Start", "MYSTIK_mod"], function(values) {         setAttrs({             MYSTYK: values.MYSTYK_Start + MYSTYK_MOD         });     });      });      </script>
1486396769

Edited 1486397259
David
Sheet Author
I doubt you can call sendChat, look in the console there is probably an error like unknown token. &nbsp;Try using console.log("your message"). &nbsp;If you not just sending the message to chat to test the sheet worker and areactually trying to display a message to the players then I had the same problem and Kryx gave me the solution&nbsp; <a href="https://app.roll20.net/forum/post/4584589/sheet-wo" rel="nofollow">https://app.roll20.net/forum/post/4584589/sheet-wo</a>...
Hi David, thanks for the information "sendChat" doesn't work with the sheetworker. Indeed I don't want to show any message to the players, I just want to check if the event is fired. I changed to just the console.log but there is no reaction in the API output console. &lt;script type="text/worker"&gt; on("change:mystik_start", function() { &nbsp;&nbsp; &nbsp;console.log("MYS changed"); }); &lt;/script&gt; Unfortunately this doesn't get an output either. If you have another method to check this, I'd like to see this. As little test I log all chat messages from an API script with the following code and this works fine. on("chat:message", function(msg) { &nbsp;&nbsp;&nbsp; log('Message received from:'); &nbsp;&nbsp;&nbsp; log(getObj('player', msg.playerid)); });
1486439572
Lithl
Pro
Sheet Author
API Scripter
When you use console.log in a sheet worker, the log will appear in the browser's &nbsp;console, not in the API console. You can access the browser console with Ctrl+Shift+J
1486455029

Edited 1486455057
Jakob
Sheet Author
API Scripter
You might also want this part: MYSTYK: values.MYSTYK_Start + MYSTYK_MOD to be this instead: MYSTIK: values.MYSTIK_Start + values.MYSTIK_mod You should also decide on some kind of consistent case convention, everything's a wild mix of upper case and lower case, which is bound to lead to some hard-to-catch bugs. My recommendation is to make everything lower case.
omg, what a mistake... lesson 1 for debugging: check the spelling... of yourse you are right Jakob. After using the correct speling on all attributes and parsing them to int before summing them up it works as intended. Many thanks. The casing of MYSTIK was inteded as this one of the essential attributes in this system such as HP. But with the suffix you are right that should be homogeneous. I'll chage this. Also thanks to you Brian. I didn't know that it was the browser console which the log is adressed to. This helps me a lot.