
I'm trying to convert all my NPCs on the pathfinder community sheet to public rolls (they are /w gm now). Doing it by hand would take forever as there is 100+ NPC's There is 2 attributes: PC-Whisper and NPC-Whisper . When these do not exist (by default), setting them with a sheet worker does not change the output of that attribute, despite the sheet showing the correct one. For example NPC-Whisper current can be 2 variables " " or "/w gm". On the sheet when the script below runs, creates/updates the attribute and sets it to " " and the attribute looks correct. But when I do a roll that calls that attribute, it's adding the "/w gm" to the message, As if it was still set to this: The only way I can get it correct is to go switch the dropdown for that attribute in the sheet manually. Is there something I'm missing with setWithWorker so it knows the new attribute correctly? It even logs correctly that none are set to '/w gm'. [This just goes thru, finds all the NPC's not assigned to controlled by anyone and sets the 2 attributes to ' '] function SETWHIS() {
var characters = findObjs({ _type: "character" });
_.each(characters, function (id) {
var PC = id.get("controlledby");
var anpc = findObjs({ _type: "attribute", name: "is_npc", _characterid: id.id}, { caseInsensitive: true })[0];
var isNPC = 1;
if(anpc != undefined){
isNPC = anpc.get('current');
}
var PCwhisp = findObjs({ _type: "attribute", name: "PC-Whisper", _characterid: id.id}, { caseInsensitive: true })[0];
var NPCwhisp = findObjs({ _type: "attribute", name: "NPC-Whisper", _characterid: id.id}, { caseInsensitive: true })[0];
if(PCwhisp == undefined) {
createObj("attribute", {name: "PC-Whisper",current: "",characterid: id.id});
}
if(NPCwhisp == undefined) {
createObj("attribute", {name: "NPC-Whisper",current: "",characterid: id.id});
}
if(isNPC == 1 && PC == "") {
PCwhisp.setWithWorker('current', "");
NPCwhisp.setWithWorker('current', "");
//--------
var PC = PCwhisp.get("current");
var NPC = NPCwhisp.get("current");
log(id.get("name") + " IsNPC: "+ isNPC + " NPCSETTING: " + NPC + " PCSETTING: " + PC);
}
});
}