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

TurnMarker1 Modification to (un)set status icon at start of each turn

1608474900

Edited 1608474949
I'm looking to send a token-mod command at the start of every character's turn (PC & NPC) to turn off a "Reaction Used" icon. I currently use TurnMarker1 so I figure I "just" need to find the appropriate place to add a sendchat command, but I don't know where that is or what I would need to do to select the token before sending the command. Is this super easy for anybody to explain to me? Thanks for your help!
1608481338
Victor B.
Pro
Sheet Author
API Scripter
You could use Combat Master to issue the token-mod command.  Combat Master has within the initiative menu the ability to issue an API against all Player Tokens or All Tokens on the map at the start of each round.  This is done without having to select tokens.  I don't know how many people are using this functionality.  To implement you'd need to add an --as-api to the token-mod command, add --ids <tokensubstitutionstring> and create a substitution string.  The substitution string is tied to the token id and CM will pull the token id and replace the substitution string with the token id of all player tokens or all tokens on the map.  
1608484510

Edited 1608484522
The Aaron
Roll20 Production Team
API Scripter
Probably easier to just have a custom script that will do this.  Change the ReactionStatus to whatever status you use for reactions.  It's case sensitive (because statuses are) and be sure to use the Tag version if there is one (the one followed by ::#####, it's listed in [ ] on TokenMod's help). Script: const ClearReactionStatus = (()=>{ // eslint-disable-line no-unused-vars // config const ReactionStatus = ' Eye_Balls::2591986 '; //////////////////////////////////////// const statRegex = /^([\w-]+(?:::\d+)?)(@\d)?/; const getTurnArrayFromString = (str) => ( '' === str ? [] : JSON.parse(str)); const statusMarkersWithoutStatus = (statuses,marker) => statuses.filter((s)=> marker !== (s.match(statRegex)||[])[1]); const handleTurnOrderChange = (obj,prev) => { let to = getTurnArrayFromString(obj.get('turnorder')); let po = getTurnArrayFromString(prev.turnorder); const toID = (to[0]||{id:'to'}).id; const poID = (po[0]||{id:'po'}).id; // turn changed if(toID !== poID){ let t = getObj('graphic',toID); if(t){ t.set('statusmarkers', statusMarkersWithoutStatus( (t.get('statusmarkers')||'').split(/,/), ReactionStatus ).join(',') ); } } }; on('chat:message',(msg)=>{ if('api' === msg.type && /^!eot(\b\s|$)/i.test(msg.content)){ let prev = JSON.parse(JSON.stringify(Campaign())); setTimeout(()=>handleTurnOrderChange(Campaign(),prev),100); } }); on('ready',()=>{ on('change:campaign:turnorder', handleTurnOrderChange); }); })();
1608500886

Edited 1608500942
Amazing - thanks Aaron! To be clear how to I change this to either set vs unset vs toggle?
1608503435
The Aaron
Roll20 Production Team
API Scripter
This only unsets. You'd still use something like: !token-mod --set statusmarkers|+Eye_Balls::2591986 To set it.  I'm not sure what the circumstance would be for toggling, but you could do that on a single token with TokenMod: !token-mod --set statusmarkers|!Eye_Balls::2591986
Ok perfect thanks