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

Another Question

1627613982
Ergo
Pro
Marketplace Creator
So I wanted to use the script Hidden Role Messages and it wouldn't work. I was getting an error on an undefined object. I tracked it down to this bit of code: this.iden_length = this.HRM_identifier.length;  Looking over the code I found this:         let dice_sides = 20;         let HRM_identifier = "!!!";         if(globalconfig){             dice_sides = globalconfig.dice_sides;             HRM_identifier = globalconfig.HRM_identifier;         } So I tried commenting that out and it worked. My assumption (and I hate assuming anything about code, so I'll say hypothesis instead :)) is that globalcingfig always exists and if the vars don't exist in it then these lines of code are setting them to undefined. Do I understand this correctly? Would a check like  if ( typeof   HRM_identifier  !== 'undefined' ) be appropriate? Thanks
1627628204
GiGs
Pro
Sheet Author
API Scripter
The issue here might be the same in your other thread. You can't use this on roll20 (at least, I don't think you can - I'm not as familiar with the API as sheet workers).
1627659156
Ergo
Pro
Marketplace Creator
This doesn't seem to be an issue as both scripts are now working with it. But I'll hit the docs.
1627660050

Edited 1627662809
timmaugh
Forum Champion
API Scripter
I don't think the this is a problem, GiGs... Fairly certain that you can use this  at least in a class (as this script does) since ES6. Maybe the guidance you're referring to was issued before ES6 made its way to Roll20? Or that the this gets remapped in arrow functions: const bestFunk = () => {...} EDIT : I failed to read the JSON of the script before posting. Those properties (of the globalconfig object) are set at the script's configuration page. If you go to your script page, do you have values in the fields for those properties?
1627662383
Ergo
Pro
Marketplace Creator
I imported it originally and it wouldn't work so I took it as a learning oppotunity.
1627662837
timmaugh
Forum Champion
API Scripter
See my edit, above. That was my fault for a post that didn't really answer the question.
1627663271
Ergo
Pro
Marketplace Creator
Yes, I entered the properties and they defaulted in case you didn't. Still didn't work. I don't need to change them so I just skipped it in the code.