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

[bug] Accessing Obj Status Marker Virtual Property doesn't work

Hello, I had this error while extracting the status of the "red" status marker from one of my tokens. It was with the "red" status active (set by hand, together with some other statuses selected), and when I got it using obj.get('status_red') it kept returning "false". Accessing 'statusmarkers' it returned the string including "red", so it was clearly there.
1384950429
Gauss
Forum Champion
To confirm, this is an API bug?
I have the same problem with "dead". I know "yellow" works. <a href="https://app.roll20.net/forum/post/470240/#post-470" rel="nofollow">https://app.roll20.net/forum/post/470240/#post-470</a>... Here's my workaround. var isAlive = obj.get("statusmarkers").split(',').indexOf("dead")==-1;
@Gauss Yes, it is an API bug. @Lifer4700 Yep, it's what I'm doing, though I just use obj.get("statusmarkers").indexOf("red") since there is only one possible status of the token that contains the string "red".
1384956432
Gauss
Forum Champion
Fabio, thanks, moved to the API forum. :)
1384957481

Edited 1384957565
Fabio M. said: since there is only one possible status of the token that contains the string "red". For now... Wait... what? How can .indexOf() be used without making it an array first?
They are actually different functions. Think of it as String#indexOf and Array#indexOf. The first tells you the position of a substring within a string, the other tells you the index of an item within an Array. If you look at the output of String#indexOf, it won't be the word position, but the actual letter position of the substring.
1384972068

Edited 1384972114
Ok, that makes sense. Thank you! Although, if - in the future - they add a status called, say, "feared" I'm guessing the String#indexOf(red) would pick that up, but what about using the split + Array#indexOf(red)? would that pick it up, or does it have to be an exact match of the array element? DISCLAIMER : I'm learning Javascript as I work with Roll20.
Is this on Dev or Main or both?
In that case, the split would work better - Array#indexOf requires an exact match.
Dev Server, didn't try it on Main. @Lifer4700 As John M said, yYou're right, but since in my environment my tokens have a script "controlled" state I didn't bother creating an array out of the statusmarkers string.
@Fabio What is the current value of your full "statusmarkers" string? It seems to be working properly for me on a simple test case.
Actually nevermind, I think I figured it out. Both "red" and "dead" should be working now. Let me know if it's not. Note that this is on Dev.
1385012503

Edited 1385012544
Verified fixed on Dev
Thanks!