
Hey, hopefully this issue isn't too blindingly obvious and I'm not being silly but I was banging my head away trying to solve this yesterday and didn't really get a satisfying fix and it's just broken the update I wanted to push to CorpseCart (as I broke the ability to remove tokens from the map layer with the release version). My current issue is this function: //FIND CORPSES TO DEL OR MAP
function findCorpses(mapID,corpseCom){
var corpseTokensAll = findObjs({
_type:"graphic",
_subtype: "token",
status_dead : true,
layer: "objects",
_pageid: mapID,
});
if (corpseCom==comDel){
let corpseTokensAllMap = findObjs({
_type:"graphic",
_subtype: "token",
status_dead : true,
layer: "map",
_pageid: mapID,
});
log(typeof corpseTokensAllMap);
corpseTokensAll.push(corpseTokensAllMap);
log(typeof corpseTokensAll);
}
log("Stage FC1");
corpseTokensAll = corpseTokensAll.filter(t => t.get('represents') !== "");
log("Stage FC2");
var corpsetokens = corpseTokensAll.filter(t => getObj('character',t.get('represents')).get('controlledby') == "");
log("Stage FC3");
if (corpsetokens===undefined || corpsetokens.length == 0){
sendChat("Corpse Cart", "/w gm No corpses found to cart.",null,{noarchive:true})
return;
}
else{
log("Number of Corpses to Cart: "+corpsetokens.length);
corpseCom == comDel ? corpsetokens.forEach(deleteCorpses) : false;
corpseCom == comMap ? corpsetokens.forEach(buryCorpses) : false;
sendChat("Corpse Cart", "/w gm Carted away " + corpsetokens.length + " corpses.",null,{noarchive:true})
}
log("Stage FC4");
} What this does is grabs all tokens with the dead marker on the object layer, adds those on the map layer if the command (corpseCom) was to delete them (comDel) and then filter for NPCs before sending to the move to map or deletion functions. Issue is that only and only for deletion it is throwing the error every time of: TypeError: t.get is not a function
at apiscript.js:28781:71
at Array.filter (<anonymous>)
at findCorpses (apiscript.js:28781:38)
at apiscript.js:28720:6
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:70:8)
at /home/node/d20-api-server/api.js:1739: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) My log shows that Stage FC1 and then the error being thrown, so it's definitely t.get("represents") causing an issue, and apparently only of something on the map layer, as object layer runs fine. On blank maps it goes ok, and this is a map that is deliberately filled with half built and malformed/disconnect tokens and graphics to check for real use conditions. I'm at a loss for what it is and why I cannot just filter it out, doesn't every subtype:token have a represents field that I should be able to filter via? Sorry if my understanding and particularly jargon is limited, my background is not coding or backend work at all!