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

My "sheet-worker" does not work

1587062679

Edited 1587066261
Hello, I am new to this site since the arrival of the Corona Virus. I was GM in IRL club and I make my own game. So since I have to animate my game on Roll20 I begin to create a custom caracter sheet. I did the HTML and I now want to add Sheet-workers. So I made the most basic program possible in order to start. Problem it does not work (The sheet-worker)! As it often happens to me I think it's a basic error but I still spent 5 hours on it without finding it. So I ask for your help. The concerned Part of my HTML : &lt;DIV&gt; Manipulation : &lt;input type="number" name="attr_manipulation" value="0"/&gt; % Mouvement&nbsp; : &lt;input type="number" name="attr_mouvement" value="0"/&gt; % Vision : &lt;input type="number" name="attr_Vision" value="0"/&gt; % &lt;/DIV&gt; &lt;script type = "text/worker" &gt; on("change: manipulation", function () { getAttrs(["mouvement"],&nbsp; function (values) { let manip = values.mouvement + 100; setAttrs({ manipulation: manip }); }); }); &lt;/script&gt; Thank you in advance for your help Note : I am French so sorry for the English errors that there may be. If you are French-speaking and you have a little time to devote to helping the most void I give you the link of a tutorial on the caractersheet which unfortunately is not finished. <a href="https://docs.google.com/document/d/13mq32wWiJOPCZH_saWHKJ3BcsBqvVQXfaS3GSjxOjy8/edit#heading=h.a3zdllg6w314" rel="nofollow">https://docs.google.com/document/d/13mq32wWiJOPCZH_saWHKJ3BcsBqvVQXfaS3GSjxOjy8/edit#heading=h.a3zdllg6w314</a>
1587063068
Kraynic
Pro
Sheet Author
I'm probably the last one that should be looking at sheetworkers, but I was looking at "change: manipulation" First, it looks like there is a space between the : and the m which I don't think is supposed to be there, but also shouldn't that be watching for a change in mouvement instead of manipulation, since it is adding 100 to mouvement to create the manipulation score?&nbsp; Should it be "change:mouvement"?
1587063289

Edited 1587063349
GiGs
Pro
Sheet Author
API Scripter
You have two potential errors I see immediately: change: manipulation This includes a space between change: and manipulation. Spaces in the wrong places, like here, will cause the worker to fail. It must be change:manipulation The second possible error is let manip = values.mouvement + 100; Attribute values in a character sheet are stored as words (the technical term is strings), not numbers. values.movement will give you something like "15". Note the quotes-&nbsp; they are part of the value. You cant do "15" + 100, that will produce "15100" - it will treat both as words, and join them one after the other. You need to convert that to a number. There are numerous ways to do that, but the most common is parseInt. Its best to do it this way: let mouve = parseInt(values.mouvement) || 0; let manip = mouve + 100; The first line converts the values.mouvement to an integer, and then the || 0 at the end says "if the bit before this is an error, set to 0". Without it, if the mouvement attribute on the character sheet holds a value that cant be converted into a number, the worker would crash on this line. This avoids that. With those two changes, your worker looks like (edit: &nbsp;updated with kraynics observation about mouvement - well spotted!) on("change:mouvement", function () {&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;getAttrs(["mouvement"],&nbsp; function (values) { let mouve = parseInt(values.mouvement) || 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let manip = mouve + 100; setAttrs({ &nbsp;&nbsp;&nbsp;&nbsp;manipulation: manip });&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;}); }); Hopefully that'll get your worker working.
I applied your comments but unfortunately it didn't work. In view of this basic program and your comments I think that this is not an error directly related to the Sheet-Worker. So I explored other possibilities. Looking in the attributes of a caracter sheet I see the 2 Atributes. I also tested on a completely empty part and the Sheet-Worker does not work. By this I mean that there is no interaction with my Caracter-sheet.&nbsp; I have activated data modification for all players : And i dont find other potential problem. Do you have an Idea ? Thanks for helping me so quickly : )
1587068309
GiGs
Pro
Sheet Author
API Scripter
None of those things should affect this. Can you post the entire html file to pastebin.com or gist.github.com? If the sheet worker isnt working, its suggesting there is something else in the code interfering. What do you mean by this? I also tested on a completely empty part&nbsp; There's only one way to test this sheet worker: by entering a different number in the mouvement attribute.
I just took the part concerned by the Sheet-Worker here it's my Html : <a href="https://github.com/camillelecourt/Rimworldroll20/blob/master/Html.html" rel="nofollow">https://github.com/camillelecourt/Rimworldroll20/blob/master/Html.html</a> here it's my CSS : <a href="https://github.com/camillelecourt/Rimworldroll20/blob/master/CSS.css" rel="nofollow">https://github.com/camillelecourt/Rimworldroll20/blob/master/CSS.css</a> The html is not optimized.
I think you need double quotes (" ") around manipulation in the setAttrs command.
1587071951
GiGs
Pro
Sheet Author
API Scripter
Actually Rabulias, you don't. You only need quotes there if the attribute isnt a javascript legal word, like ones that contain dashes. And either kind of quote will do. JSON is stricter, and does need double quotes, which is likely where you;ve got that from, but javascript objects dont need that.
1587072226
GiGs
Pro
Sheet Author
API Scripter
Camille l. said: I just took the part concerned by the Sheet-Worker here it's my Html : <a href="https://github.com/camillelecourt/Rimworldroll20/blob/master/Html.html" rel="nofollow">https://github.com/camillelecourt/Rimworldroll20/blob/master/Html.html</a> here it's my CSS : <a href="https://github.com/camillelecourt/Rimworldroll20/blob/master/CSS.css" rel="nofollow">https://github.com/camillelecourt/Rimworldroll20/blob/master/CSS.css</a> The html is not optimized. The first thing I notice is your Mouvement attribute is spelled with a capital letter. Do one of the following (not both): First Option Change the attribute name in the input Mouvement : &lt; input type =" number " name =" attr_mouvement " value =" 0 "/&gt; % Second Option Alternatively, change the attribute case in the sheet worker: on("change:mouvement", function () { getAttrs(["Mouvement"], function (values) { let mouve = parseInt(values.Mouvement) || 0; let manip = mouve + 100; setAttrs({ manipulation:manip }); }); }); notice how the first line is still in lower case. That's confusing but correct - change events must always be lower case. Any other line must match the attribute's case. Does this fix it?
Sorry It dont change anything
1587072947
GiGs
Pro
Sheet Author
API Scripter
I installed it and found the error, and it was one I'd never seen before. So we all learn something today. This is the issue &lt;script type = "text/worker" &gt; You cant have the spaces in there. It has to be &lt;script type="text/worker"&gt;
1587073384
GiGs
Pro
Sheet Author
API Scripter
As an addendum I finally got around to testing something I've been meaning to do for over a year but keep forgetting. I suggested this earlier on("change:mouvement", function () { getAttrs(["Mouvement"], function (values) { let mouve = parseInt(values.Mouvement) || 0; let manip = mouve + 100; setAttrs({ manipulation:manip }); }); }); It turns out though that attribute case only matters on the change line, where it must always be written in lower case. On the other lines, you can write using whatever case you like, it doesnt have to match the attributes in the character sheet. This is why you should never have two attributes that differ only in the case: having "strength" and "STRENGTH" - as far as roll20 is concerned, those are the same attribute.
Thank you very much it works. The problem was: &lt;script type = "text / worker"&gt; The good form it's this : &lt;script type="text/worker"&gt; Thank you for helping me so quickly and with such efficiency Thanks also for the help for the attributes I will post my sheet on this post when it will be finish
1587128720
GiGs
Pro
Sheet Author
API Scripter
Youre welcome :)