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

Struggling with sheet worker

I'm working on a custom sheet for a Cortex prime game. I have a sheet worker that runs when the checkboxes attached to the attritbutes res1a or res1b are checked or unchecked. It's incomplete at the moment, and I've disabled some the functionality to try to focus on the error, but I'm stuck.     on('change:res1a change:res1b' ,(event)=>{         console.log(`============================ resource setting detected ============================`);         console.log(event);         console.log(`========================================================`);         var checked = event.newValue         if(checked === '0') {               console.log(`============================ not checked ============================`);               console.log(checked);               console.log(`========================================================`);           } else {               console.log(`============================ checked ============================`);               console.log(checked);               console.log(`========================================================`);               getAttrs('resources_dice', function (values) {                   console.log(`============================ resources dice ============================`);                   //console.log(values);                   console.log(`========================================================`);                   //setAttrs({'resources_dice':values['resources_dice'] + ';' + checked});               });             }     }); This fires when the checkbox is checked and unchecked. When the checkbox is checked, I get this in the console. ============================ resource setting detected ============================ {sourceAttribute: "res1a", sourceType: "player", triggerName: "res1a", previousValue: "0", newValue: "d10"} ======================================================== ============================ checked ============================ d10 ========================================================  Uncaught TypeError: Cannot use 'in' operator to search for '0' in resources_dice     at Function.C.each.C.forEach      at Worker.<anonymous>     at Worker.<anonymous> I don't understand what the issue is, I think I've created the resources_dice attribute with the code <input name='attr_resources_dice' type='text' value='x'> For full current context, the current sheet is in a git repo  (forked from the main Roll20 repo) in a folder called Cortex prime. Can someone give me a steer?
1592212813
Kavini
Pro
Marketplace Creator
Sheet Author
Compendium Curator
I don't know that this will resolve your issue, but getAttrs takes an array as the first parameter, rather than a string. So you would replace: getAttrs('resources_dice', function (values) { With: getAttrs(['resources_dice'], function (values) {
Oh dear, poor javascript punctuation was my downfall.  The other getAttr sections I wrote took an array variable as the list of attributes to get  and I clearly got confused about what the [] was doing. Thanks, will have some questions which might actually be hard, once I've got the sheet mostly constructed.