Tomc0 Posted August 30, 2013 Share Posted August 30, 2013 Hello guys, I need some help with one my scripts: I need a timer, that counts the playtime of the player. So, if I have a code like that: playTime = 0 function updateTimer() playTime = playTime + 1 end setTimer(updateTimer,60000,0) How I can format the "playTime" variable like that: 1h,24m? Because right now, I just have a variable like "81 minutes" what is lame as hell. So can you guys help me with switching minutes to hours? Yes, I know, I could do that like this: if(playTime >= 60) then playTime = "1h 0m" end But that's not good, because I can't do it forever. So, thanks for the help! Link to comment
bandi94 Posted August 30, 2013 Share Posted August 30, 2013 function return_Played_time(time) local h,m if time/60 >= 1 then h = math.floor(time/60) m = time - h*60 else h=0 m=time end return tostring(h.."h "..m.."m") end Link to comment
Tomc0 Posted August 30, 2013 Author Share Posted August 30, 2013 Thank you very much. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now