
I found an API that automatically adds hit dice rolled to your character sheet as well as deduct the hit die and informs you if you have no hit die or if you are at max hp. I have 2 problem the first and most sever is that for some reason that I can not find it does not work on all of my players character sheets. it works on 3 of the 4. I have tried this API in a completely different game and 2 out of 10 character sheet in that game did not work and by not working I mean that there is no evidence that the API is even in the game. there is no errors or wrong exsiccation just a normal hit die roll. the second and far more miner is that it it does not work with the show hit die per class option at all. I assume because it is displayed completely differently and I do not possess the skill or knowledge to change the character sheet or adapt the API. any help would be appreciated. the API is as fallows: on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) { var cnamebase = msg.content.split("charname=")[1]; var cname = cnamebase ? cnamebase.replace('}}','').trim() : (msg.content.split("{{name=")[1]||'').split("}}")[0].trim(); var character = cname ? findObjs({name: cname, type: 'character'})[0] : undefined; if(["simple"].indexOf(msg.rolltemplate) > -1) { if(_.has(msg,'inlinerolls') && msg.content.indexOf("^{hit-dice-u}") > -1 && character) { handlehd(msg,character); } } } }); // CHECK CURRENT HD, DECREMENT HD, THEN APPLY HP var handlehd = function (msg,character) { var hd = findObjs({type: 'attribute', characterid: character.id, name: "hit_dice"}, {caseInsensitive: true})[0]; var hp = findObjs({type: 'attribute', characterid: character.id, name: "hp"}, {caseInsensitive: true})[0]; if(!hd || hd.get("current")==="" || hd.get("max")==="") { log("CHARACTER HAS NO HIT_DICE ATTRIBUTE OR HD CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HD attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else if(!hp || hp.get("current")==="" || hp.get("max")==="") { log("CHARACTER HAS NO HP ATTRIBUTE OR HP CURRENT/MAX IS NULL"); sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + "HP attribute on " + character.get("name") + " is missing or current/max values are not filled out, Hit Points were not applied." + "</span></div></div></div>"); return; } else { var curhd = parseInt(hd.get("current")); var newhd = curhd - 1; } var maxhp = parseInt(hp.get("max")); var curhp = parseInt(hp.get("current")); if (curhd === 0) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " has no HD remaining, HP were not applied." + "</span></div></div></div>"); } else if (curhp === maxhp) { sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>" + character.get("name") + " already at full HP, no HD used." + "</span></div></div></div>"); } else { hd.set({current:newhd}); var result = msg.inlinerolls[2].results.total ? msg.inlinerolls[2].results.total : false; var newhp = curhp + result; if(result === false) { log("FAILED TO GET HD RESULT"); } else if (newhp > maxhp) { hp.set({current:maxhp}); } else { hp.set({current:newhp}); } } };