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

Script: TurnTimer

Hello, In case anyone needs this, here is a simple script that creates a Text object which counts down from 45 seconds (or whatever amount of time you want). The text is placed next the current character token from the turn order, on the gm layer. The countdown updates once per second using the system clock (I believe it will keep accurate time even under lag). You don't need to enter any API commands. The script will listen for a change in the Turn Order and create a new timer automatically. When the turn changes, if there is any remaining time, the current clock will be deleted and replaced with a new one.  When the time runs out, the current clock is deleted. At the top of the document are some customizable variables: fontSize   should be an integer TimerFont can be any roll20 font TurnTimeLimit should be an integer TimerLayer can be 'gmlayer', 'objects', 'map' or 'walls' I've uploaded the script to my Github  here . Here's a screenshot: -Michael
Neat-o
I'm going to borrow this code for sure.  May tweak it to count up (rather than down), and reset back to zero for each turn.  
1694224332
The Aaron
Roll20 Production Team
API Scripter
That seems handy! Since the API is a flat scope, you should wrap your script in: on('ready', ()=>{ // code here }); :to create a closure and protect the global scope.  I might suggest adding a chat listener and set a timeout to check the turnorder for a change if you see !eot or !pot. Those are the commands that TurnMarker1 (and some other scripts) use for advancing the turn order. API changes don't trigger events (for the most part), but watching for the trigging commands and the. Waiting a little will let you still react appropriately. 
@The Aaron - great idea to wrap it in the on ready event listener! I updated the code. Actually, I should have mentioned above - I had already added an event listener for the !eot and !pot commands!
Really Neat! Is there a way to customize this to count minutes instead of seconds? (e.g. 60 Minutes instead of 3600 seconds)
1694287090

Edited 1694287139
@TheMarkus1204 - Great idea. You'll still need to set the  TurnTimeLimit in seconds, but the timer will display in minutes when there is more than 60 seconds on the clock. Also, thanks to you I found, and fixed, a bug where the old timer wasn't fully reset when returning to a player before their old time ran out. Thanks!