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

On("change:graphic:turn")?

Does anyone have a simple method to get an event when the turn tracker advances and/or a new round starts?  I've seen `change:campaign:turnorder`, but that appears to be changes to the actual turn order (like Fred now goes before Ralph).  I'm not looking to implement a replacement initiative system or alternate turn tracker, I just want to get notified when the tracker advances.  I have this sinking feeling that roll20 doesn't emit any such event...?
1542807681

Edited 1542807793
Ammo
Pro
you got the right event. &nbsp;it should fire every time you advance the marker, unless you are using another script that takes over the turn order and screws up the event for you. the turn order is just a JSON array of the things in the turn order tracker, and it does in fact change every time you advance (rotating the entries.) if you aren't seeing events, I believe you have a replacement turn tracker installed? for example code, here's a thing I was experimenting with (links to the journal entries and clickable actions) which I think I will work with Robin to add to CombatTracker instead (after making it pretty!): derScript . get_token = function ( token_flat ) { &nbsp;&nbsp;&nbsp;&nbsp; if (! token_flat ) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return undefined &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp; var token = getObj ( "graphic" , token_flat . id ); &nbsp;&nbsp;&nbsp;&nbsp; if (! token ) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; token = getObj ( "graphic" , token_flat [ "_id" ]); &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp; return token } on ( 'change:campaign:turnorder' , function ( campaign , previous ) { var token_flat = JSON . parse ( campaign . get ( 'turnorder' ))[ 0 ] &nbsp;&nbsp;&nbsp;&nbsp; var token = derScript . get_token ( token_flat ) &nbsp;&nbsp;&nbsp;&nbsp; if (! token ) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &nbsp;&nbsp;&nbsp;&nbsp;} var character_id = token . get ( 'represents' ) if (! character_id ) { return } var character = getObj ( 'character' , character_id ) var text = [] const regex = new RegExp ( `^repeating_npcaction_(-[-A-Za-z0-9]+?|\\d+)_name` ); &nbsp;&nbsp;&nbsp;&nbsp; text . push ( "next turn is for " + character . get ( 'name' )) &nbsp;&nbsp;&nbsp;&nbsp; text . push ( "<a href="https://journal.roll20.net/character/" rel="nofollow">https://journal.roll20.net/character/</a>" + character_id ) findObjs ({ type: 'attribute' , characterid: character_id }). forEach ( attribute =&gt; { var attribute_name = attribute . get ( 'name' ) if ( attribute_name . search ( regex ) === 0 ) { text . push ( "[" + attribute . get ( 'current' ) + "](~" + character_id + "|" + attribute_name . slice ( 0 , - 5 ) + "_npc_action)" ) } &nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;&nbsp;&nbsp; if ( text . length &gt; 0 ) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat ( "derScript" , "/w GM " + text . join ( ' ' ), null , { noarchive: true }) &nbsp;&nbsp;&nbsp;&nbsp;} });
PS: never mind that getToken nonsense, that's old code I copied when I was starting out. &nbsp;It deals with the fact that sometimes you have a token as just a dictionary and sometimes the Roll20 object. &nbsp;It makes me throw up in my mouth a little. &nbsp;Now I just write code that knows what type of thing it is dealing with :)