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 Help

1470542342

Edited 1470542372
First attempt at using a sheet worker. So I have an HTML select input for Power Attack. The options are 0, 1, or 2. I have the following sheet worker code in my sheet: on("sheet:opened change:meleeweapon1-pwratk", function() {     getAttrs(["meleeweapon1-pwratk"], function(value) {         switch(value.meleeweapon1-pwratk) {             case "0":                 setAttrs({                     "meleeweapon1-pwratk-attack": "",                     "meleeweapon1-pwratk-damage": ""                });             break;             case "1":                 setAttrs({                     "meleeweapon1-pwratk-attack": "+ (?{Power Attack? (put in penalty with negative sign ie -3 (Max of -@{BAB})|0}) [Pwr Atk]",                     "meleeweapon1-pwratk-damage": "+ [[abs(?{Power Attack? (put in penalty with negative sign ie -3 (Max of -@{BAB})|0})]] [Pwr Atk]"                });             break;             case "2":                 setAttrs({                     "meleeweapon1-pwratk-attack": "+ (?{Power Attack? (put in penalty with negative sign ie -3 (Max of -@{BAB})|0}) [Pwr Atk]",                     "meleeweapon1-pwratk-damage": "+ [[2*abs(?{Power Attack? (put in penalty with negative sign ie -3 (Max of -@{BAB})|0})]] [Pwr Atk]"                });         }     }); }); The select input is changing the value to 0, 1, or 2, but the sheet worker never seems to set the other two attributes. I must be missing something (probably something simple). Any help would be appreciated. Thanks!
1470546356
Lithl
Pro
Sheet Author
API Scripter
Dumb "is the power on" type question: are meleeweapon1-pwratk-attack and meleeweapon1-pwratk-damage disabled (autocalc) fields, readonly fields, or user-editable? You cannot set the value of disabled fields with sheet workers.
Thanks for the reply. They are normal text inputs right now so I can see if they get set. I have the initial value="" for each of them. Should I not set an initial value? Once this is working I would like to change their input type to hidden. Can sheet workers affect hidden inputs?
1470578833
Lithl
Pro
Sheet Author
API Scripter
Setting an initial value is fine. Sheet workers can affect hidden inputs just fine. It's only disabled inputs they can't touch.
So I built a minimal test case with the same logic and it worked fine. That led me to the solution: apparently the sheet workers do not like dashes in the attribute names. I renamed my fields to use underscores and updated the sheet worker code accordingly and it works great. Thanks again for the answers to my questions, Brian!
1470591203
Lithl
Pro
Sheet Author
API Scripter
Dashes should work fine in attribute names, the problem would be the "variable.property-name" syntax for accessing them, since a dash is not a legal character for that. However, you can use "variable['property-name']" just fine.