itunes89
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 1957 |
|
|
| 08 Nov 2012 11:25 AM |
It converts to minuets. Also adds a leading zero in the seconds.
IE: print(sec2Min(61)) -->1:01
function sec2Min(secs) if secs > 59 then myMinutes = math.floor(secs/60); mySeconds = secs-(math.floor(secs/60)*60) if mySeconds < 10 then mySeconds = "0"..mySeconds; end myTime = myMinutes..":"..mySeconds; else mySeconds = secs if secs < 10 then mySeconds = "0"..secs; end myTime = "0:"..mySeconds; end return myTime
end
|
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 11:28 AM |
I did this as one of my first few scripts :/
function translate(s) return tostring(math.floor(s/60)) .. ":" .. tostring(s%60) end |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 11:30 AM |
Fixed to add the leading zero
function translate(s) return tostring(math.floor(s/60)) .. ":" .. (s%60>10 and tostring(s%60) or "0" .. tostring(s%60)) end |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 11:31 AM |
Whoops. Wrong number.
function translate(s) return tostring(math.floor(s/60)) .. ":" .. (s%60>=10 and tostring(s%60) or "0" .. tostring(s%60)) end |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 08 Nov 2012 11:52 AM |
| ^Mr. Professional right here. |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 08 Nov 2012 12:47 PM |
^
Not really, that's simple. That's what he was trying to show [I think]; it doesn't require 50 lines of code. |
|
|
| Report Abuse |
|
|
RA2lover
|
  |
| Joined: 09 Nov 2008 |
| Total Posts: 1254 |
|
| |
|
|
| 08 Nov 2012 02:10 PM |
" mySeconds = secs if secs < 10 then mySeconds = "0"..secs;"
The longer I stare at this, the more I think that this script isn't what he was trying to show us. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 08 Nov 2012 02:20 PM |
| @Arceus. Possibly he lives in land, where seconds lesser than 10 automaticly become 0. OMT INFINITE TIME! |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 08 Nov 2012 02:21 PM |
Mah bad, I'm day dreaming to much :(
if secs < 10 then secs = 0 end
There, enough of daydreaming for me. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Nov 2012 02:50 PM |
| ♪♫♪♪♫♫♫♪♫♪♪♫♪♫♫♫♫♪♪♫♪♫♫♪♫♪♫♫♪♫♫♪♪♫♪♪♫♪ |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 08 Nov 2012 02:51 PM |
♫♪ YOLO ♫♪
Actually yolo sounds like good shizz for song or idk.. |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 02:55 PM |
Rap. Not music. Trololol
y-y-y-yolo yolo yolo yolo yooooooolo |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 08 Nov 2012 03:08 PM |
Simplest yet:
("%d:%02d"):format(math.floor(secs / 60), secs % 60) |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 08 Nov 2012 03:50 PM |
("%d:%02d"):format(math.floor(secs/60),secs%60) 5 characters shorter noob |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 08 Nov 2012 03:56 PM |
| I didn't say short, I said simple. Mine is simpler to read. |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 03:58 PM |
("%d:%02d"):format((secs-secs%60)/60,secs%60)
2 characters shorter. Noobs. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 08 Nov 2012 04:01 PM |
| SN0X, I'm afraid that was a pun. |
|
|
| Report Abuse |
|
|
|
| 08 Nov 2012 04:01 PM |
s=secs ("%d:%02d"):format((s-s%60)/60,s%60)
2 characters shorter. Noobs. |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 08 Nov 2012 04:03 PM |
*sigh* - another character shorter:
s=secs;n=s%60;("%d:%02d"):format((s-n)/60,n) |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
| |
|
|
| 08 Nov 2012 04:11 PM |
Can someone explain how this guy came to be a wiki writer again?
*sigh* |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
| |
|
| |
|