generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Seconds to Minuets converter(Something I whipped up)

Previous Thread :: Next Thread 
itunes89 is not online. 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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
08 Nov 2012 11:52 AM
^Mr. Professional right here.
Report Abuse
SN0X is not online. 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 is not online. RA2lover
Joined: 09 Nov 2008
Total Posts: 1254
08 Nov 2012 02:01 PM
also, minuets.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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 is not online. 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 is not online. 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
awsumpwner27 is not online. awsumpwner27
Joined: 03 Sep 2011
Total Posts: 4389
08 Nov 2012 02:27 PM
♫♪
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
08 Nov 2012 02:50 PM
♪♫♪♪♫♫♫♪♫♪♪♫♪♫♫♫♫♪♪♫♪♫♫♪♫♪♫♫♪♫♫♪♪♫♪♪♫♪
Report Abuse
zars15 is not online. 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
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
08 Nov 2012 02:55 PM
Rap. Not music. Trololol

y-y-y-yolo
yolo yolo yolo
yooooooolo
Report Abuse
NXTBoy is not online. 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 is not online. 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 is not online. 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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
08 Nov 2012 03:58 PM
("%d:%02d"):format((secs-secs%60)/60,secs%60)

2 characters shorter. Noobs.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
08 Nov 2012 04:01 PM
SN0X, I'm afraid that was a pun.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
08 Nov 2012 04:01 PM
s=secs ("%d:%02d"):format((s-s%60)/60,s%60)

2 characters shorter. Noobs.
Report Abuse
NXTBoy is not online. 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 is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
08 Nov 2012 04:04 PM
(late post)
Report Abuse
TheCapacitor is not online. TheCapacitor
Joined: 19 Jan 2011
Total Posts: 7045
08 Nov 2012 04:11 PM
Can someone explain how this guy came to be a wiki writer again?

*sigh*
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
08 Nov 2012 04:20 PM
Who? Me or ArceusInator?
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
08 Nov 2012 04:21 PM
I think he means itunes.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image