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 Workers] Help with setAttrs

1480119340
Finderski
Pro
Sheet Author
Compendium Curator
I'm working on making my character sheet configuration easier to work with for published settings by having a one-click set up for the setting.  Some of the settings have different names for money (i.e. Pirate themed settings typically use Pieces of 8, while sci-fi settings seem to like credits, etc.) and so I have a field named: attr_50fPo8Clams When I try to use setAttrs to set that field name, my sheet workers freak out and stop functioning. I'm guessing it's because of the number in the first position of the field name? Is there anyway around this, short of having to rename the field (which I'd rather not do, because that would be a sheet-breaking change.  So, am I right in my assumption and what can I do about it?
1480121307
Lithl
Pro
Sheet Author
API Scripter
In javascript, a number is not a legal starting character for an identifier, so you can't do something like: setAttrs({ 50fPo8Clams: 10 }); However, fear not! There is a solution. Object properties can also be strings, so you can  do this: setAttrs({ '50fPo8Clams': 10 });
1480133174
Finderski
Pro
Sheet Author
Compendium Curator
Awesome! Thanks, Brian. That worked like a charm!