About time
quantumsheep
Member Posts: 8,188
Hey all!
Just a quickie about timers.
Now, I can make and display a timer that shows how many seconds are left. Or count up. That's all fine.
How do I display these seconds as minutes though? And hours? Anyone know off the top of their head?
Cheers,
QS
Just a quickie about timers.
Now, I can make and display a timer that shows how many seconds are left. Or count up. That's all fine.
How do I display these seconds as minutes though? And hours? Anyone know off the top of their head?
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Comments
Hour=floor(game.Timer/3600)
Minute=floor((game.Timer%3600)/60)
Seconds=(game.Timer%60)
But thanks! I think. How would that appear in a rule, as in, how do you display it?
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
or something like that
A VERY HAPPY QS!!!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
When it gets down to single digits, no 0 is displayed.
For example, four minutes and six seconds should read:
4:06
Instead it reads:
4:6
BAH!
Anyone got a solution? I think displaying stuff like this would be useful to a lot of people.
Especially me!
Otherwise I'll just have to resort to displaying seconds. Which is a bit rubbish...
Cheers in advance,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
floor( game.TimeTaken /3600)..":"..floor((floor( game.TimeTaken /60)%60)/10)..(floor( game.TimeTaken /60))%10..":"..floor(( game.TimeTaken %60)/10)..game.TimeTaken %10
In before CodeMonkey, who showed me that!
Any typos are mine... but provided there aren't any, that string should give you the time broken down digit-by-digit, so for example a time of one second should display as 0:00:01.
Thank you both!
QS
Aha! Your version doesn't work, alas, Cobra.
On the plus side, that's the longest string I've ever put into a game, so a first there!
I need to sleep - been up all night and I'm making silly mistakes. So I'll try again in a few hours.
Thanks again for the input!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
floor( self.myTime /3600)..":"..floor(floor(( self.myTime %3600)/60)/10)..floor((floor( self.myTime %3600)/60)%10)..":"..floor(( self.myTime %60)/10).. self.myTime %10
I am so confused now (X_x)
(though I generally disapprove of Math, I'll let this one slide)
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io