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

In Search Of: A simple(?) stopwatch

1411844537
Gen Kitty
Forum Champion
I'd like to be able to use a stopwatch script. It would have a token somewhere on the map, the token would do 'something' to reflect the passage of seconds after I activate the script, it would count down 30 seconds and then send a note to chat, but here's the kicker: I want to be able to STOP the script before it finishes counting down. The intended use is to speed up combat rounds. Players get told it is their turn, I give warnings at 30 and 60 seconds, and at 90 seconds I fiat the character does something simple/nobrainer if the player hasn't started taking their turn. I've been using a physical stopwatch, but I'd really like to have something ingame that people can see.
I don't have mentor status, so I can't test the specifics, but here's how I'd handle it: 1) Create a token for your timer (if you want to get fancy, use a table with a few images of an hourglass or wall clock at various progress states). 2) Set one bar (I'll call it "running") to 0, and another (I'll call it "counter") to 90 / 90. 3) Declare a function (I'll call it "timerTick()") which decrements counter if running!=0 (for the fancy case, also set the token to the appropriate sprite frame based on counter.current / counter.max). 4) var timerId = setInterval(timerTick, 1000); This will cause your timerTick function to be called every second. 5) Set running=1 to start your timer counting down; set running=0 to stop it. 6) If necessary, you can call clearInterval(timerId) to stop the every-second calls to timerTick.
1411862507
Gen Kitty
Forum Champion
I should have been more specific. :> I'm looking for an existing script that meets the design spec, or hoping someone will write such a script for general use. In the meantime, I have a 34 second Jeopardy Theme Song sound clip that will do the job nicely!
1411866303

Edited 1411866443
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
<a href="https://app.roll20.net/forum/post/154950/script-ho" rel="nofollow">https://app.roll20.net/forum/post/154950/script-ho</a>... Not sure if its exactly what you need... but I would start there.