Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Set attribute with Worker. But output is still old setting.

1563900322

Edited 1563900789
DXWarlock
Sheet Author
API Scripter
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); } }); }
1563903957
The Aaron
Roll20 Production Team
API Scripter
You'll probably need to dig into the sheet workers and see what they do. I think setWithWorker() is currently broken. :/
1563903990
The Aaron
Roll20 Production Team
API Scripter
See:&nbsp; <a href="https://app.roll20.net/forum/post/7440478/api-no-longer-triggering-sheet-workers#post-7632212" rel="nofollow">https://app.roll20.net/forum/post/7440478/api-no-longer-triggering-sheet-workers#post-7632212</a>
1563905910
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yes, please post examples to that thread. The devs have asked for specific cases.
1563906372
DXWarlock
Sheet Author
API Scripter
Thanks Aaron And will do Keith, let me make sure its not a ID10T error on my end first I've been known to trigger those a lot, I'll dig into the sheet see what it does on the dropdown change and what it calls to make sure I didn't miss something first.
1563907182
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey dx, may be more than you need for this, but the pfc should be able to help with this. Additionally, you shouldn't need to set with worker as this isn't a change that is propagated to other attributes, it's simply called by macros, so doing a loop to check for the attribute on all NPCs, creating it if it doesn't exist and then setting it to /w gm should take care of it.
1563913958
The Aaron
Roll20 Production Team
API Scripter
(Could also be a PEBKAC error... =D )