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

[HELP] How to find specific attributes?

I'm incredibly new to this whole API thing - just got to working on it yesterday, really. I can't figure something out, though; how would one find the attributes attached to a character sheet, and access them? For example, I want one attribute to change based on the value of another. Currently my code is: on("change:attribute", function(obj) {   //When mental or physical attributes are changed, prints what target numbers become.   if(obj.get("name") == "Physical" || obj.get("name") == "Mental") {   var base = getObj("character",obj.get("_characterid"))   if(obj.get("current") >= 10) {sendChat(base.get("name"),"I am now unconscious from " + obj.get("name") + " damage!");}   else if(obj.get("current") >= 6) {sendChat(base.get("name"),"I now have a +3 to my Target Numbers from " + obj.get("name") + " damage!");}   else if(obj.get("current") >= 3) {sendChat(base.get("name"),"I now have a +2 to my Target Numbers from " + obj.get("name") + " damage!");}   else if(obj.get("current") >= 1) {sendChat(base.get("name"),"I now have a +1 to my Target Numbers from " + obj.get("name") + " damage!");}   else if(obj.get("current") == 0) {sendChat(base.get("name"),"I am completely healed of my " + obj.get("name") + " damage!");}   }}); and as I said, I'd really like to be able to change another attribute based on those values. It's probably incredibly simple and I'm just looking right over it, but any help is greatly appreciated! Best regards, James W.
Use var allattributes = findObjs("attribute", {"_characterid": base.id}); It should return an array of all attributes for the character (after you've defined base).
so, on("change:attribute", function(obj) {     var allattributes = findObjs("attribute",{"_characterid": obj.id}); } Should work? EDIT: fixed typos