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

Possible trouble with getAttrs and setAttrs

1453208932
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
I am trying to track down some very weird behavior on my character sheets. Specifically, the console log is consistently saying ReferenceError: Damage_max is not defined(…)    When it most certainly should be defined - and in fact I can see the value in Attributes and Abilities. I am also finding that token values that I have linked to attributes will suddenly be blank. For example if bar 2 max is supposed to be a number around 40, the actual value will be blank.  Anyway, I wrote some short test code to try to duplicate the behavior in a limited space, and came up with this.  <input type="number" name="attr_a"  value="5">  <input type="number" name="attr_a_max" value="10">  <br> <input type="number" name="attr_b"  value="15">  <input type="number" name="attr_b_max" value="110">  <br> <input type="number" name="attr_c"  value="25">  <input type="number" name="attr_c_max" value="210">  <!-- WORKERS --> <script type="text/worker">     on("change:a", function() {         'use strict'; log("change a");         getAttrs([ "c", "c_max" ], function(values) {            'use strict'; log( values[ "c" ] + "  and  " + values[ "c_max"] );             setAttrs({  "b": values[ "c" ], "b_max": values[ "c_max"]   });         });     }); // End on change wt-test1 </script> It is a pretty useless screen, just 6 boxes that you can change at random. Whenever you change a or a_max, it copies whatever is in c and c_max into b and b_max.  I have spent some very boring time just changing numbers. Sometimes I had some of the numbers linked to a tokens bars, but both times the problems occurred when the character sheet was not linked to a token.  There seems to be no way to consistently reproduce the trouble. It is just random. I have tried every combination of ways to change these numbers that I can, and everything will work fine for sometimes very long stretches of time (20 minutes or more). But twice now this very simple program has gotten itself messed up.  The first time I had been clicking the increment and decrement twirlers on the number boxes when I noticed it was not copying the numbers from c to b. The console log had a message which I stupidly did not write down, but it was something about max being no good (but it was not the message quoted above "c_max is not defined(…) ") In fact I seem to recall that it was not (something)_max at all, it said "max was (something)". (I know that this vagueness is pretty useless) Looking in the Attributes and Abilities, I noticed that c_max was blank. I had never set it to blank, I had always set it to an integer using only the increment and decrement twirlers. I deleted c in attributes and Abilites, and changed the values some more and the sheet created a new "c" and it was quickly working perfectly again.  After a very long period of time I got it to mess up again, but in a totally different way. Suddenly the setAttribs stopped working. I still see the messages "changed a" and the values of c and c_max in the console log, but it has stopped updating b and b_max at all. Once again, the worker threads are still running, because I still see the console log. It is just very quietly not setting the new values.  Anyway, I am about done bashing my head on this for the day and was hoping that somebody might offer some guidance.  Thanks. 
Chris -- do you happen to have the game handy where you did this testing? I want to take a look at the underlying data and see if there are any red flags in there. Also, just to be sure, when did you do this testing, and was it on Dev or Main? We actually had several changes to the Sheet Workers and whatnot go out throughout the day yesterday so I just want to make sure you weren't testing in the middle of all that. If you were testing after about 9 PM Central last night it shouldn't have affected you.
1453217151
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
The original campaign I was having trouble with was on the main server, and I was having troubles with it today, including about 6 hours ago, but I am not certain that the problem might not be corruption, and it could have gotten corrupted yesterday about that time.  The test campaign is on the Dev server and is named ChrisD Test and there is really never anything in that campaign except whatever small code fragment I am trying to isolate. The problems happened maybe 3 to 4 hours ago. I will PM you an invite to the test campaign, and if you want I can make you a GM (as soon as I notice you took the invite) so you can look under the hood. 
Okay. So Dev and Main are actually running different code right now (Main is actually more up to date currently). We're working on some other stuff for Dev to release this week and we can't push out the bug fixes that are already on Main until those new features are ready to go on Dev. So you're best bet would be to transfer your Test Case to Main and see if you still see the issue there. However, that said, what I think would actually be best after re-reading your original post, is to just give me a link to the game where you were originally seeing the "Damage_max is undefined" error so I can take a look at that game directly and see if I can figure out why you're seeing that error, since it may not be related to your Test Case.