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

status_back-pain: true for token status markers

I am trying to write a script that automatically applies certain token status symbols when a characters hit points reach a certain level. And it wall works fine if I use any token name that does not contain the character "-" in it. I cant figure out how to call those status symbol names in javascript without their being an error due to the "-" symbol. Any help for a javascript newb would be helpful.
Pass the status as a literal string 'status_back-pain'. For example token.set('status_back-pain', true); token.set({'status_back-pain': true});
SyntaxError: Unexpected token . is what I get with both of those :\
1504392391
The Aaron
Pro
API Scripter
That probably has to do with copy/pasting from the forum and getting some weird unicode characters.  Try just typing in the first one.
1504392450
The Aaron
Pro
API Scripter
Also, if you post that section of your code, it will be easier to look for other issues.
1504392472
The Aaron
Pro
API Scripter
Syntax errors are often reported on lines that don't contain the actual issue.
1504434325

Edited 1504448232
Arioch1973
Sheet Author
This is the wounded.js script I am using. And typing it in instead of copying did not work, it still gives the same syntax error message. I want to change status_skull to status_back-pain, if possible. It just hates the "-" in there. on("change:graphic", function(obj) {     if(obj.get("bar3_value") <="") return;     if(obj.get("bar3_value") <= 3) {         obj.set({             status_redmarker: true         });     }     else{         obj.set({             status_redmarker: false         })     }     if(obj.get("bar3_value") <= 0) {         obj.set({             status_skull: true         });     }     else {         obj.set({             status_skull: false         });     } });
1504448725
The Aaron
Pro
API Scripter
This should work: on("change:graphic", function(obj) {     if(obj.get("bar3_value") <="") return;     if(obj.get("bar3_value") <= 3) {         obj.set({             status_redmarker: true         });     }     else{         obj.set({             status_redmarker: false         })     }     if(obj.get("bar3_value") <= 0) {         obj.set('status_back-pain', true);     }     else {         obj.set('status_back-pain', false);     } });
Awesome, that did it. Thank you very much. :)
1504461376
The Aaron
Pro
API Scripter
No problem!  Happy Rolling!