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 .
×

Field Name For Party Identifier?

1786927312

Edited 1786927388
This pertains to an AD&D 1e campaign, but I believe the character property I am looking for may be universal, I'm not sure. When you select a number of characters and select "Define party": When you edit a character sheet, you can see (and change manually if you want) the Party Member check box checked or not checked, as highlighted below: I use Roll20 javascript. How can I refer to the property of that check mark? I have a number of Mod scripts where I would like effects to be limited to only characters where the  Party Member  check mark property is turned on. Thanks for any help on this.
1786941796

Edited 1786942117
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Tim! It's in the tags property. I don't recall the exact tag off the top of my head, but you can find it with the Inspector script by Timmaugh. EDIT:    tags: ["_roll20_internal_party_tag_"],
1786989014
The Aaron
Roll20 Production Team
API Scripter
Actually, Character has inParty which is the preferred way with Mod Scripts to set/remove it. if(!character.get('inParty')){ character.set('inParty',true); } There's using it both ways as an example.
1786989259

Edited 1786989922
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thank for that, Aaron! I had at one point considered a "Party Manager" script for handling Westmarches style games, where the party composition would change often. Does setting "inParty" toggle the tag automatically? And does manipulating the tag directly have any affect on inParty?
The Aaron said: Actually, Character has inParty which is the preferred way with Mod Scripts to set/remove it. if(!character.get('inParty')){ character.set('inParty',true); } There's using it both ways as an example. Thanks both Aaron and Keith. I think the above is a bit easier for me at this time. 
1787071322
The Aaron
Roll20 Production Team
API Scripter
The Mod Script Server doesn't do anything with that tag, that's purely a VTT UI thing.  I don't think adding it causes the VTT to set inParty either, though I'd need to test.  I would treat that as a side effect.
The Aaron said: The Mod Script Server doesn't do anything with that tag, that's purely a VTT UI thing.  I don't think adding it causes the VTT to set inParty either, though I'd need to test.  I would treat that as a side effect. Your suggestion is working really well though. It replaces this convoluted if I had concocted based on controlledby and character names: if (controlledBy && controlledBy !== "" && controlledBy !== "gm" && controlledBy !== "-Owmnu2o8CrK7Hzyo2Gk" && chr.get("name").toLowerCase() !== "macromule") It had a LOT of "leaks"
1787152091
The Aaron
Roll20 Production Team
API Scripter
Yeah, it's nice when things can bet simplified! =D Side note, there's no controlledby setting of "gm" because the GM can control everything.  Here's a couple functions you might find handy for dealing with control: const playerCanControl = (obj, playerid='any') => { const playerInControlledByList = (list, playerid) => list.includes('all') || list.includes(playerid) || ('any'===playerid && list.length); let players = obj.get('controlledby') .split(/,/) .filter(s=>s.length); if(playerInControlledByList(players,playerid)){ return true; } if('' !== obj.get('represents') ) { players = (getObj('character',obj.get('represents')) || {get: function(){return '';} } ) .get('controlledby').split(/,/) .filter(s=>s.length); return playerInControlledByList(players,playerid); } return false; }; const getControlList = (obj) => { let list = obj.get('controlledby') .split(/,/) .filter(s=>s.length); if('' !== obj.get('represents') ) { list = [...new Set([ ...list, (getObj('character',obj.get('represents')) || {get: function(){return '';} } ) .get('controlledby').split(/,/) .filter(s=>s.length) ])]; } return list.join(','); }; Two Functions: playerCanControl( object, optionalPlayerID) -- takes a graphic or character and returns true if a player can control it.  Handles "all", and looking at the represented character as well.  Optionally pass a playerID to check if that specific player can control it. getControlList( object ) -- takes a graphic or character and returns the composite list of controlledby entries.
The Aaron said: Yeah, it's nice when things can bet simplified! =D Side note, there's no controlledby setting of "gm" because the GM can control everything.  Here's a couple functions you might find handy for dealing with control: Thank you very much. I've bookmarked this.