Hi all, i am trying to get this api script to work, but i am receiving this error that i dont know how to fix, can anyone help me please? var CHOSEN_STATUS = "strong";
var STRATTR = "Str-Mod";
var CONATTR = "Con-Mod";
var HPATTR = "HP";
var ACATTR = "AC";
var LEVATTR = "Level";
on("chat:message", function(msg) {
if (msg.type == "api" && msg.content.indexOf("!Rage") !== -1) {
_.each(msg.selected, function(objInfo) {
var obj = getObj(objInfo._type, objInfo._id);
if( obj.get("_type") == "graphic" ){
if( obj.get("_subtype") == "token" ){
var charID = obj.get("represents");
var StrAttr = findObjs({
name: STRATTR,
_type: "attribute",
_characterid: charID
}, {caseInsensitive: true})[0];
var ConAttr = findObjs({
name: CONATTR,
_type: "attribute",
_characterid: charID
}, {caseInsensitive: true})[0];
var HPAttr = findObjs({
name: HPATTR,
_type: "attribute",
_characterid: charID
}, {caseInsensitive: true})[0];
var ACAttr = findObjs({
name: ACATTR,
_type: "attribute",
_characterid: charID
}, {caseInsensitive: true})[0];
var LevAttr = findObjs({
name: LEVATTR,
_type: "attribute",
_characterid: charID
}, {caseInsensitive: true})[0];
if( obj.get("status_"+CHOSEN_STATUS) ){
sendChat("Rage-API", obj.get("name")+" toggling off.");
//log(StrAttr.get("current")+" "+ConAttr.get("current")+" "+ACAttr.get("current")+" "+HPAttr.get("current")+" "+LevAttr.get("current"));
obj.set("status_"+CHOSEN_STATUS, false);
StrAttr.set("current", parseInt(StrAttr.get("current"))-4);
ConAttr.set("current", parseInt(ConAttr.get("current"))-4);
HPAttr.set("current", parseInt(HPAttr.get("current"))-(2*parseInt(LevAttr.get("current"))));
ACAttr.set("current", parseInt(ACAttr.get("current"))+2);
//log(StrAttr.get("current")+" "+ConAttr.get("current")+" "+ACAttr.get("current")+" "+HPAttr.get("current")+" "+LevAttr.get("current"));
} else
{
sendChat("Rage-API", obj.get("name")+" toggling on.");
//log(StrAttr.get("current")+" "+ConAttr.get("current")+" "+ACAttr.get("current")+" "+HPAttr.get("current")+" "+LevAttr.get("current"));
obj.set("status_"+CHOSEN_STATUS, true);
StrAttr.set("current", parseInt(StrAttr.get("current"))+4);
ConAttr.set("current", parseInt(ConAttr.get("current"))+4);
HPAttr.set("current", parseInt(HPAttr.get("current"))+(2*parseInt(LevAttr.get("current"))));
ACAttr.set("current", parseInt(ACAttr.get("current"))-2);
//log(StrAttr.get("current")+" "+ConAttr.get("current")+" "+ACAttr.get("current")+" "+HPAttr.get("current")+" "+LevAttr.get("current"));
}
}
}
});
}
}); And this is the error i am getting. TypeError: Cannot read property 'set' of undefined TypeError: Cannot read property 'set' of undefined at apiscript.js:49:32 at Function.each (/home/node/d20-api-server/node_modules/underscore/underscore.js:1310:9) at apiscript.js:13:11 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1662:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)