On my character sheet I have a checkbox called attr_is_npc. I want the API to watch for a change in that field and when that field is checked I need to change some Attributes that exist on that character sheet. I know I can use several functions to get the specific Attributes but for the life of me, I can't figure out how to assign the _characterid to a variable so I can make those calls. So, can someone point me in the right direction? How do I set it up to watch for a change in that particular ability (is_npc), and then get the id of the character that change was for? I have tried multiple things, but this is the closest I seem to get: on("change:attribute", function(obj){
var cID = obj.characterid;
var oID = obj.id;
log(obj);
log("Object ID: " + oID);
log("Character ID: " + cID);
});
This is the output I get: {"name":"is_npc","current":"1","max":"","_id":"-KJ8reNsB60Jr9T9kNbE","_type":"attribute","_characterid":"-KJ8prwV5tFCPW3Fu711"}
"Object ID: -KJ8reNsB60Jr9T9kNbE"
"Character ID: undefined"
So, I can see the character ID, but can't seem o assign it to anything. Why does the oID assignment work, but the no cID assignment? Thanks.