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 Question] Adding Time to Hourglass

[GitHub]

Anyone familiar with how this script works enough to know if a function could be added in which the timer can be increased while it's counting down?

Use example: I set Hourglass for 10:00, starting the countdown. Encounter allows the time remaining to increase by 2 minutes whenever the party finishes certain tasks. New command is entered, asks how much time I would like to add. I enter 02:00, and the time increases without interruption.

Could this function be easily added to the script (if it would even work)?

June 26 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Definitely doable. I'll try to add that tonight. 

Thank you! I tried manually increasing the minute bar value by +2 while it's counting down, but it would revert to what it was before. So I wasn't certain it was possible.

June 27 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Here ya go!  https://gist.github.com/shdwjk/1e4deb1b9096dd4d4fd038db24e63b37

!hg add 1:23
!hg sub 1:20:23

Same syntax as the start command.  I added both "add" and "sub" (or "subtract").

Cheers!

Fantastic! Testing it out now, I am noticing that if I start the timer, add time, then subtract time, it ends at 1 second remaining. Other than that, though, it's functioning perfectly :)

June 27 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter
yeah, now that I'm thinking about it, I might need to change the way they count time. I'll give it another test later tonight.
June 27 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I made a quick update to https://gist.github.com/shdwjk/1e4deb1b9096dd4d4fd038db24e63b37

I neglected to update the cut off timer they're using, so it was not finishing when it was supposed to.  I'll see if I can clean that script up a bit more at some point.  It is actually fairly inaccurate because it ticks off seconds using a 1 second interval.  However, intervals are not not precise, which means it could end up taking 80 seconds to count 60 intervals.  What it SHOULD do is mark the expected end time, and then wake up on some interval to adjust the display based on the elapsed time, likely a higher resolution interval, like every 250ms.  You can see that they ran into this problem and tried to fix it by having a cutoff timeout that only suffers from one instance of the counting delta.

June 27 (5 years ago)

Edited June 27 (5 years ago)

Oh, I see what you mean! I did test your update against a normal timer, and it seems synchronized enough currently. It still seems to end at 1 second remaining if I add or subtract any amount of time. If I start it without making adjustments, it continues all the way to 0.

I am including some minor changes to the script myself, but it seems to be doing this without the changes, too.

(just using // to omit lines 65 and 126, and adding a function you'd recommended to someone else here)

June 27 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Cool.  I might just write a brand new timer system, so any thoughts you have on what it should do would be cool. =D

June 27 (5 years ago)

Edited June 27 (5 years ago)

Okay! I was thinking the other day that maybe a function where the time remaining is posted to chat or whispered to certain players at custom intervals (I'm thinking fractions or specific time increments/values) would come in handy?