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

How do I read a character's attributes?

I use findObjs() to fetch the characters, and now I want to loop over their individual attributes; can I do that?
1392155466

Edited 1392155547
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
<a href="https://wiki.roll20.net/API:Objects#Finding.2FFilt" rel="nofollow">https://wiki.roll20.net/API:Objects#Finding.2FFilt</a>... var currentPageGraphics = findObjs({ _pageid: Campaign().get("playerpageid"), _type: "graphic", }); _.each(currentPageGraphics, function(obj) { //Do something with obj, which is in the current page and is a graphic. }); That is for graphics but it the same idea
I saw that, I'm not sure what you mean for me to do with it?
1392155836
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
var characterNamedBob = findObjs({ _type: "character", name: "Bob", }); var characterNamedBobID = characterNamedBob[0].get("_id") var characterNamedBobAttributes = findObjs({ _type: "attribute", _characterid: characterNamedBobID, }); _.each(characterNamedBobAttributes, function(obj) { //Do something with obj, which is in the current page and is a graphic. });
1392156163

Edited 1392157222
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
//Or something like this var characters = findObjs({_type: "character"}); _.each(characters, function(eachCharacter) { var charactersAttributes = findObjs({_type: "attribute", _characterid: eachCharacter[0].get("_id")}); _.each(charactersAttributes, function(eachCharactersAttributes) { //Do something with each character's attrbute. }); });
Ah, now I get it. I was befuddled by everything being a flat structure, but it's linked withe the _id. Thanks!