How do you format a stopwatch

Post Reply
Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

How do you format a stopwatch

Post by Silvine » Fri Dec 10, 2010 7:21 pm

Hopefully a simple one. I want to use a stopwatch to display how long I have been logged on. It runs off a trigger from the welcome message, and updates to a status window every tick. But how do I format the stopwatch to show hours, mins, seconds?
I did try another approach that stored my login time in a variable and the tick time in another variable, but could not get one to subtract from the other as they are strings.
An answer to either or both approaches would be helpful, Thanks.

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: How do you format a stopwatch

Post by Silvine » Sat Dec 11, 2010 1:19 am

Got it sorted for what i want it to do. I'll post answer in case its of use to anyone else.
Use a stopwatch that starts when you log in, then on the tick get the stopwatch time and then convert it into your own clock.
Code: [show] | [select all] lua
currenttimestop = getStopWatchTime(logtimestop)

seconds = currenttimestop % 60 
minutes = ((currenttimestop - seconds) / 60) % 60
hours = (((currenttimestop - seconds) /60 - minutes) / 60) % 60

echo( "status", "You have been playing "..hours..":"..minutes..":"..seconds.."\n")

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests