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

Removing certain Token Markers while using TurnMarker1

Hi reader! Trying to help my GM out - we use TurnMarker1 in the game and we wanted a way to remove certain Token Markers at the start of a PC/NPC turn. I found the below from Three of Swords (original post here:&nbsp; <a href="https://app.roll20.net/forum/post/1513795/script-automatically-remove-status-markers-from-tokens" rel="nofollow">https://app.roll20.net/forum/post/1513795/script-automatically-remove-status-markers-from-tokens</a>) &nbsp;which I adapted to remove the Token Markers we wanted for our game... //Currently this script will remove Held Actions and Reaction Used status marker when a //combatant's turn comes up using the Turn Tracker. //Add or remove any status effects you want to be cleared to the array (list) below. var statusMarkersToBeRemoved = [ "status_dd-heldaction::4328823", "status_reaction-used::6483760", ] on('change:campaign:turnorder', function(obj) { var c = Campaign(); var pre_turnorder = c.get('turnorder'); var turn_order; if (!pre_turnorder) { return; } try { turn_order = JSON.parse(c.get('turnorder')); } catch (e) { log(e); return; } if (!turn_order.length) { return; } var turn = turn_order.shift(); var currentToken = getObj('graphic', turn.id); statusMarkersToBeRemoved.forEach(function(opts) { if (currentToken.get(opts)) { currentToken.set (opts,false); } }) }); However, the MOD only removes the specified Token Markers when we use the R20 turn tracker, and would like to have it work with TurnMarker1 - any suggestions would be greatly appreciated, even if it involves another solution! Thanks for your time!
Hi Rich, So by default API Mods do not trigger events, I believe this is to prevent some infinite loop situations that would crop up. So in order to get events to propagate from one Mod to another, the original Mod that performs the action needs to expose something that you can then register with your Mod above. For example, this is from TokenMod about registering TokenMod changes with another Mod: API Notifications API Scripts can register for the following notifications: Token Changes &nbsp;-- Register your function by passing it to&nbsp; TokenMod.ObserveTokenChange(yourFuncObject); . When TokenMod changes a token, it will call your function with the Token as the first argument and the previous properties as the second argument, identical to an&nbsp; on('change:graphic',yourFuncObject); &nbsp;call. Example script that notifies when a token's status markers are changed by TokenMod: on('ready',function(){ &nbsp;&nbsp;if('undefined'&nbsp;!==&nbsp;typeof&nbsp;TokenMod&nbsp;&amp;&amp;&nbsp;TokenMod.ObserveTokenChange){ &nbsp;&nbsp;&nbsp;&nbsp;TokenMod.ObserveTokenChange(function(obj,prev){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(obj.get('statusmarkers')&nbsp;!==&nbsp;prev.statusmarkers){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sendChat('Observer&nbsp;Token&nbsp;Change','Token:&nbsp;'+obj.get('name')+'&nbsp;has&nbsp;changed&nbsp;status&nbsp;markers!'); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;} }); So in the above you see that TokenMod exposes a function and this new Mod uses that to get notified of changes. I'm by no means a JS expert but a quick check of TurnMarker1 doesn't seem to have that same type of function within it, although TurkMarker1 does check for GroupInitiative changes for itself. So you might be able to fork TurkMarker1 to add that function to register with your above Mod or perhaps The Aaron can stumble on this thread and add that ability to TurnMarker1.
1720105001

Edited 1720105035
Rich
Pro
Thanks, Joshua, Greatly appreciated. Funnily enough I stumbled across a GitHub link to an older version of TurnMarker1 [1.3.12] ( <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/TurnMarker1/1.3.12/TurnMarker1.js" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/TurnMarker1/1.3.12/TurnMarker1.js</a> ), so will have a play with your suggestion and the old version to see if I can make anything work (though I am no JS expert either!) and just hope that The Aaron stumbles on in in the meantime.