+The Silvas Posted May 22, 2014 Share Posted May 22, 2014 Hi, I can get the number of seconds left from my timer using: ztimerClock.Remaining However, this just returns the seconds. I want to convert that into easier to read time. Something like: You have 3:23 left. Can anyone help with how to do this? Thanks Quote Link to comment
Ranger Fox Posted May 22, 2014 Share Posted May 22, 2014 Something like this: local sec, min sec = ztimerClock.Remaining % 60 min = (seconds - sec) / 60 Wherigo.MessageBox{Text="You have " .. min .. ":" .. sec .. " left."} Quote Link to comment
+The Silvas Posted May 23, 2014 Author Share Posted May 23, 2014 min = (seconds - sec) / 60 Hi, thanks for the quick reply, however something is not quite right. You said (seconds - sec) / 60 and because seconds is not a variable it gives an error. I tried min = ztimerClock.Remaining / 60 however this gives a number with a lot of decimal points. Thanking you in advance. Quote Link to comment
Ranger Fox Posted May 23, 2014 Share Posted May 23, 2014 local sec, min sec = ztimerClock.Remaining % 60 min = (ztimerClock.Remaining - sec) / 60 Wherigo.MessageBox{Text="You have " .. min .. ":" .. sec .. " left."} And that's what I get for rewriting code before I post it. I originally had it defined as a function where seconds was a parameter, then I rewrote part of it and didn't notice I still had that variable inside. Anyway, after each line, here are the values: sec = 0, min = 0, ztimerClock.Remaining = 203 sec = 23, min = 0, ztimerClock.Remaining = 203 sec = 23, min = 3, ztimerClock.Remaining = 203 "You have 3:23 left." Quote Link to comment
+The Silvas Posted May 26, 2014 Author Share Posted May 26, 2014 Great, thanks so much for this. Quote Link to comment
+ionka Posted October 2, 2015 Share Posted October 2, 2015 Can I ask about this conversion? How to do this in Urwigo? Where should I write this lua code? I know this topic is very old, but nobody can aswer my question. I cant programming. I can only treat people. Please help me. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.