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 .
×
May your rolls be chill this holiday season!
Create a free account

findObjs behavior that appears strange - is it a bug or mis usage of myself ?

Hello I'm using findObjs in a script, and searching a simple character object with the following code var characters = findObjs({ _type: 'character', controlledby: playerId }); It appears that if the character is controlled by 2 persons, like playerId and playerId1, the findObjs object does not find any character. It seems like it is searching through the exact string match instead of finding the playerId in the list of players Am i doing right ? Is it the expected behavior of findObjs ? In that case, will i need to get all objects and parse myself in the API or is there another method ? Thanks for inputs
Correct, it is searching for the exact string in the controlledby field. On top of my head the following should do the trick: var characters = findObjs({type:'character'}).filter(c => c.get("controlledby") && c.get("controlledby").indexOf(playerId)>-1))