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 .
×

Can findObjs handle a != parameter ?

1592319138
Carpe
API Scripter
Hi all, this might be a very quick 'No' I'm doing the below to get tokens that have a value in represents, is it possible to do a field is not blank check in findObjs or is filter the way? var AllTokens = findObjs({_type: "graphic", layer: "objects", subtype: "token" });     AllTokens = AllTokens.filter(function(token){         var represents = token.get("represents");         return PCIds.includes(represents);     });
1592319579
The Aaron
Roll20 Production Team
API Scripter
You'll need to filter for that, something like: var AllTokens = findObjs({type: "graphic", layer: "objects", subtype: "token"})     .filter(token=>PCIds.includes(token.get("represents") && token.get('name').length !== 0);
1592320000
Carpe
API Scripter
thanks that's cleaner
1592320344
The Aaron
Roll20 Production Team
API Scripter
Btw, it's a good idea to always use !== and === instead of != and == unless you really understand the difference (at which point you'll always use !== and === because you understand the difference. =D).
1592322973
Carpe
API Scripter
TIL javascript can do cross object comparison madness! ty 0 == false // true 0 === false // false, because they are of a different type 1 == "1" // true, automatic type conversion for value only 1 === "1" // false, because they are of a different type null == undefined // true null === undefined // false '0' == false // true '0' === false // false
1592323320
The Aaron
Roll20 Production Team
API Scripter
My favorite (humorous) video about it:&nbsp; <a href="https://www.destroyallsoftware.com/talks/wat" rel="nofollow">https://www.destroyallsoftware.com/talks/wat</a>