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

[HELP] Turn Marker Modification

I'm using The Aaron's Turn Marker script, and I'd like to modify it to add a chat button for the !eot command.  Specifically, on a PC's turn, instead of the little box that announces the player's name, I'd like it to have a little "End Turn" button.  I know I can use something like [End Turn](!eot) in a macro to create a button, but where and how could I place that code in the script to get the button to come up on a PC's turn?
1445003867
The Aaron
Pro
API Scripter
At about line 509, where it says +PlayerAnnounceExtra, add the bold line below:                     +'</div>'                     +'<div><a href="!eot">End Turn</a></div>' /* line 509 */      +PlayerAnnounceExtra                 +"</div>" I've actually got that in the version I'm using right now, though in a different place.  
Cool!  I'll test it out later. 
It works - is there a way to make the button just show up when it's a PC's turn?  If not, this will work just fine. Just curious, if you wanted it to just perform an api command at a certain point, without the button, what would that look like?  Specifically, I've got a simple clock script I'm using to keep time, but sometimes I forget to increment the clock after every round.  It would be nice to add in that command when the new round starts up.  The api command would be !ttaddsec 60
1445052484
The Aaron
Pro
API Scripter
You might be able to get away with adding something like: sendChat('','!ttaddsec 60'); at the right place, but I'm not sure if API commands can be triggered that way, I'd have to experiment.  The better way is to set up a way that the increment can be activated with a function call, and then call it in the right place.  The best way is to setup something like the observer pattern, the way Bump and TurnMarker observe GroupInitiative and perform actions when it signals various events. 
So, in TurnMarker, would that observe pattern be this section (around line 665)?         if('undefined' !== typeof GroupInitiative && GroupInitiative.ObserveTurnOrderChange){             GroupInitiative.ObserveTurnOrderChange(TurnMarker.HandleTurnOrderChange);         }     }
1445085406
The Aaron
Pro
API Scripter
Yup!  Observer allows the dependency to be in the right direction. It requires a bit of extra wiring, but is worth it (at least to me!).   If you look at Bump, you can find a nearly identical set of code. The basic rundown: 1) The observable object (GroupInitiative) provides a registration function that allows outside code to provide a function to call when a specified event occurs. It stores the functions in a list for the event.  2) Objects that are interested in doing something when an event occurs (observers, Bump & TurnMarker) register their callback functions with the observable object 3) When the observable object performs the event, it calls each of the functions in the list for that event, possibly providing some context of the event.  At no point does it need to be aware of what the other objects are that are registering for these events.  That means you can add observers willy-nilly with no change to the observable object. :)
One thing I noticed is that the turn marker doesn't put itself under the first token in the order.  It will only move under a token if it is 2nd in the order.  I'm assuming that it can't move there until the turn advance button is clicked for the first time?  Also, is the turn marker supposed to move with the token?  Thanks!
Never mind, it wasn't playing well with the group-init script.  It doesn't like it when that script automatically displays the tracker.  If I shut down the tracker and open it again, all is well.
1447803730
The Aaron
Pro
API Scripter
hmm.. I'll look into that bug, thanks!
Yes, I set it up so that Group-Init doesn't auto-open Turn Marker, roll everyone's first initiative, and then open the tracker, and it works right.