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

Would like to change some General Options for all NPCs in my game (ChatSetAttr or TokenMod)

I have both ChatSetAttr and TokenMod in my game. I would like to change the following General Options on all NPCs: ROLL QUERIES: Always Roll Advantage WHISPER ROLLS TO GM: Never Whisper Rolls AUTO DAMAGE ROLL: Auto Roll Damage & Crit NPC NAME IN ROLLS: Hide Is there a way for me to run a single command and have them all changed? Note: When I use Apply Default Settings from My Settings, it doesn't give all those as options - only Auto Damage Roll Thanks in advance, Evan
1587055484
The Aaron
Roll20 Production Team
API Scripter
I don't think you can do it with ChatSetAttr, I know you can't with TokenMod.  However, I can probably write you a quick one-off script that will do that for you.  I'll take a look this evening.
1587056685

Edited 1587056861
The Aaron said: I don't think you can do it with ChatSetAttr, I know you can't with TokenMod.  However, I can probably write you a quick one-off script that will do that for you.  I'll take a look this evening. I've been doing it manually as it comes up, since there's nothing worse than having a "Bandit" swing at a player and the players seeing "Doppelganger" in the attack box! Thank you very much! Evan
1587062017

Edited 1587063575
Dumbhuman
Pro
Marketplace Creator
The Aaron said: I don't think you can do it with ChatSetAttr, I know you can't with TokenMod.  However, I can probably write you a quick one-off script that will do that for you.  I'll take a look this evening. It 's should be possible to do with ChatSetAttr so long as you can figure out the proper syntax for the naming and settings of those fields and don't run into the API sheet-workers issue : !setattr --allgm --rtype|always-roll-adv --wtype|never-whisper-roll --dtype|always-roll-dmg --npc_name_flag|0
1587062226
The Aaron
Roll20 Production Team
API Scripter
Oh nice!  If that works Evan, that's one less thing from my list. =D
1587063654

Edited 1587065955
Dumbhuman
Pro
Marketplace Creator
Hmmm... on further testing, that's not working the way I thought it should.  I know pieces of it can work though. --npc_name_flag|0 definitely works in isolation using --sel at least. --wtype|never-whisper-roll definitely works in isolation using --sel at least. --rtype|always-roll-adv definitely does not work. --rtype|'{{query=1}} {{advantage=1}} {{r2=\lbrak\lbrak1d20' definitely works in isolation using --sel at least. --dtype|always-roll-dmg definitely does not work. As KeithCurtis points out in the thread linked below, how to make dytpe work seems to be a mystery.
1587064087
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Note that with ChatSetAttr, there are some weird issues with the D&D 5th Edition by Roll20 sheet.
1587064691
Dumbhuman
Pro
Marketplace Creator
I really don't understand why the sheet isn't more streamlined than it is.  It just seems needlessly confusing for confusion's sake.
Well..maybe it is not what you want, but it might be worth mentioning:  If you go to the game settings, you can choose to have the settings you mentioned to be the default.  Any characters already in the game will not have their settings changed. But any creatures you pull from the compendium, and any new characters created will have the defaults you've set in the game settings.
1587067911
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
KC . said: I really don't understand why the sheet isn't more streamlined than it is.  It just seems needlessly confusing for confusion's sake. My only guess (and it is a pure guess) is that it was built by many developers, over a long period of time, each with different understandings, skill levels and coding habits, in a continually changing environment, and that there was no original master plan of development. I.e. it likely grew organically. It's extremely frustrating to try to interact with in many ways. Even the latest attempt to change one attribute name in the name of uniformity has caused ripples of broken macros. My personal desire would be to see a new sheet, built from the ground up, with an import function to pull data in from old campaigns. That would require a huge amount of work, though, and is likely fraught with problems I haven't considered. For instance, it might go hand in hand with a complete re-write of how Compendium data is stored. Also, most users probably don't see these issues and wouldn't understand why so many resources were being devoted to something that for most folks, doesn't look broken. tl;dr: Yeah it's frustrating, but it probably works "good enough"
I'm avoiding running the script that has been crossed out, but I just wanted to thank everyone who has taken a look at this to help. Worst case I'm thinking if I disable all my API Scripts I might be able to use the "Apply Default Settings," since I've had that work without any APIs but it's definitely not working now. Full disclosure: I have 19 API scripts active. Evan
1587083726

Edited 1587090712
The Aaron
Roll20 Production Team
API Scripter
Here ya go! For something like this, I suggest copying your Game and trying it on a copy first just to make sure you like the results.  I tried it on my test game and it ran pretty well.  120 NPCs in about 5-10 seconds. To use it, just run: !fix-npcs It will tell you how man it's fixing so you know what to expect, then it will tell you when it's done. Cheers! Script Code: on('ready',()=>{ const fixMap = { npc_name_flag: ()=>"0", rtype: ()=>"[{{always=1}} {{r2=[[1d20]", wtype: ()=>"", dtype: ()=>"full" }; const fixChar = (id) => Object.keys(fixMap) .forEach(a=>(findObjs({ type: "attribute", characterid: id, name: a })[0]||{set:()=>{}}).set("current",fixMap[a](id))); on('chat:message', (msg) => { if('api' === msg.type && playerIsGM(msg.playerid) && /^!fix-npcs(\b\s|$)/i.test(msg.content)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let npcIds = (findObjs({ type: "attribute", name: "npc", current: "1" })||[]).map(a=>a.get('characterid')); sendChat('',`/w "${who}" Fixing ${npcIds.length} NPCs.`); const burndown = ()=>{ if(npcIds.length){ let id = npcIds.shift(); fixChar(id); setTimeout(burndown,0); } else { sendChat('',`/w "${who}" Finished updating NPCs.`); } }; burndown(); } }); });
I'm copying the game now and will then try it. It's Waterdeep: Dungeon of the Mad Mage, so it's got a ton of content and I expect it to take a while.
The Aaron said: Here ya go! For something like this, I suggest copying your Game and trying it on a copy first just to make sure you like the results.  I tried it on my test game and it ran pretty well.  120 NPCs in about 5-10 seconds. To use it, just run: !fix-npcs It will tell you how man it's fixing so you know what to expect, then it will tell you when it's done. Cheers! Script Code: on('ready',()=>{ const fixMap = { npc_name_flag: ()=>0, rtype: ()=>"[{{always=1}} {{r2=[[1d20]", wtype: ()=>"", dtype: ()=>"full" }; const fixChar = (id) => Object.keys(fixMap) .forEach(a=>(findObjs({ type: "attribute", characterid: id, name: a })[0]||{set:()=>{}}).set("current",fixMap[a](id))); on('chat:message', (msg) => { if('api' === msg.type && playerIsGM(msg.playerid) && /^!fix-npcs(\b\s|$)/i.test(msg.content)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let npcIds = (findObjs({ type: "attribute", name: "npc", current: "1" })||[]).map(a=>a.get('characterid')); sendChat('',`/w "${who}" Fixing ${npcIds.length} NPCs.`); const burndown = ()=>{ if(npcIds.length){ let id = npcIds.shift(); fixChar(id); setTimeout(burndown,0); } else { sendChat('',`/w "${who}" Finished updating NPCs.`); } }; burndown(); } }); }); Thanks for helping me with this Aaron. However, the NPC NAME IN ROLLS is still set to SHOW Evan
The Aaron said: I don't think you can do it with ChatSetAttr, I know you can't with TokenMod.  However, I can probably write you a quick one-off script that will do that for you.  I'll take a look this evening. I believe I've worked around things by disabling all scripts and then doing the Apply Defaults thing. Seemed to work in my copied game at least, so I'm going to try in the real one (fingers crossed). Again, thanks everyone for helping me out with this! Evan
1587090768
The Aaron
Roll20 Production Team
API Scripter
Ah, it might need to be a "0" instead of a 0.  I fixed the script above, let me know if you need anything else.
The Aaron said: Ah, it might need to be a "0" instead of a 0.  I fixed the script above, let me know if you need anything else. That worked PERFECTLY! Thanks so much for the help! Evan
1587131999
The Aaron
Roll20 Production Team
API Scripter
Woot!  No problem. =D