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
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Converting seconds into minutes and seconds

Previous Thread :: Next Thread 
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:31 PM
The title explains everything. How would I do this?


Thanks!
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:34 PM
bump
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:34 PM
Oh, and the seconds I need to convert are numbers that range from 30 to 300.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:35 PM
*range from 0 and 300

Typo.
Report Abuse
Tynexx is not online. Tynexx
Joined: 11 Jul 2012
Total Posts: 1559
15 Jul 2014 04:35 PM
if seconds==60 then
minutes = minutes +1
seconds = 0
end
~Tynexx
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Jul 2014 04:36 PM
Erm, with 3rd grade math.

Seconds = # --Change # to a number
Minutes = Seconds / 60

Minutes = # --Change # to a number
Seconds = Minutes * 60
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:37 PM
I tried to do it a bit, but I have a huge headache right now and math hurts me... But I promised myself I would make progress on my game today.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:39 PM
@warspy


That didn't work... It did something like 2.5 minutes, 148 seconds... Here's the code:


Time = 0

Min = 0
Sec = 0

game.Workspace.SourceCode.Timer.Changed:connect(function(Val)

Sec = Val
Min = Sec/60

Sec = Min * 60

if Sec <= 0 then
Sec = 59
end

Time = Min.." minutes, "..Sec.." seconds"

script.Parent.Text = game.Workspace.SourceCode.TimerString.Value..Time
end)

game.Workspace.SourceCode.TimerVisible.Changed:connect(function(Val)
if game.Workspace.SourceCode.TimerVisible.Value == false then
script.Parent.Visible = false
else
script.Parent.Visible = true
end
end)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Jul 2014 04:43 PM
Min = Sec/60

Sec = Min * 60

You got them backwards. Min is Sec * 60, Sec is Min / 60
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:46 PM
Unless they'res 8,000 minutes in 100 seconds, you're incorrect .3.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:48 PM
*there's


Dear Lord, my headache is making me sound like an idiot.
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
15 Jul 2014 04:51 PM
@warspy - Your equation doesn't work.

"Min = Sec/60

Sec = Min * 60"

Using this let's see:

5 minutes and 45 seconds = 5 * 60 + 45 = 345 seconds.

345 seconds / 60 = 5.75 minutes.

How would you display 5.75 minutes? 5:75 would not be correct.
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
15 Jul 2014 04:52 PM
@tin - Now on to answering your question. I don't exactly know what you want. Do you want the time to ascend from 0:00 or descend from a certain set time such as 3:25? You didn't reall specify on that.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Jul 2014 04:53 PM
Oops sorry. I was thinking of something else XD
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 04:55 PM
Well, I have this timer for my game that is displayed in seconds, counting down from a large number such as 150 or 280. I think it would be nicer if I could convert the number into minutes and seconds, but I underwent a headache-induced ultimate brain fart... I think it's starting to go away, which is good.
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
15 Jul 2014 05:00 PM
Alright, well lucky for you I have made many countdown functions like this. Here you go:

local DigitalTime = function(Minutes,Seconds)
local StringTime = '';
local NewMinute,NewSecond = Minutes,Seconds;
if NewSecond == 0 then
NewMinute = NewMinute - 1;
NewSecond = 60;
end
for i = NewMinute,0,-1 do
repeat
Wait(1)
NewSecond = NewSecond - 1;
if NewSecond >= 10 then
StringTime = NewMinute..':'..NewSecond;
elseif NewSecond < 10 then
StringTime = NewMinute..':0'..NewSecond;
end
until NewSecond == 0;
NewMinute = NewMinute - 1;
NewSecond = 60;
end
StringTime = '0:00';
end

Easy to use:

DigitalTime(5,45) -- This would countdown from 5 minutes and 45 seconds.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 05:01 PM
Ehh... From the looks of this, it has two numbers to begin with. I'll try doing that.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 05:03 PM
Wait, nvm. That won't work as it's already deeply rooted into the system .3.

I'm not really sure if this is worth it... I thought it would be remotely easy.
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
15 Jul 2014 05:21 PM
My headache is completely gone now---I figured it out:

Min,Sec = math.modf(Val/60)

Sec = Sec*60
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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