That second callstack is crashing in this function: // AUTOMATICALLY GENERATE NPC TOKEN WHEN HP FORMULA IS ROLLED
var handlenpctoken = function(msg,character,player) {
character.get("defaulttoken", function(token) {
var t = JSON.parse(token);
if(token === "null") {
log("NPC DOES NOT HAVE A DEFAULT TOKEN");
}
else {
var page = playerIsGM(player.id) === true && player.get("lastpage") != "" ? player.get("lastpage") : Campaign().get("playerpageid");
var hp = msg.inlinerolls[0].results.total ? msg.inlinerolls[0].results.total : 0;
var img = getCleanImgsrc(t.imgsrc);
var tokenname = t.name ? t.name : character.get("name");
var represents = t.represents ? t.represents : character.id;
createObj("graphic", {
left: 140,
top: 140,
width: t.width,
height: t.height,
imgsrc: img,
pageid: page,
layer: (_.contains(["gmlayer", "objects", "map"], t.layer) ? t.layer : 'gmlayer'),
name: tokenname,
represents: represents,
bar3_value: hp,
bar3_max: hp
});
}
});
};
I'm not sure where the problem lies, but it has something to do with the cnpc character or npc default token.