#How format seconds into minutes
97 messages · Page 1 of 1 (latest)
seconds - totaltime - math.floor(totaltime/60) * 60
format the string after that and that's it
local second = totalTime%60
if second < 10 then
second = "0"..second
end
local currentTime = math.floor(totalTime/60)..":"..second
lol
for some reason it starts like a couple hours before the epoch
print(os.date("%M:%S", 600 + 5* 60 * 60))
-- 14:16:13.492 > print(os.date("%M:%S", 600 + 5* 60 * 60 )) - Studio
-- 14:16:13.492 10:00 - Edit
this will work tho
it was just 5 hours behind the epoch
;compile
local seconds = 600
print(string.format("%d:%02d", math.floor(seconds / 60), seconds % 60))
10:00
are u guys still arguing about this?
Nobody's arguing?
same thing
No, it's not 👁️👄👁️
shuddup
truly amazing
lol
use this one
i mean its not too bad if i just remove the Hours
cause its epoch time technically which is the seconds from Jan 1st 12 AM 1970
i just told u
its the number of seconds
from the epoch
which is january 1st 12 am 1970
whats the epoch :v
the epoch is a specific time and date
the most common is
the time i just told you
it was chosen by unix developers during unix's development because its convinient to work with
unix was released in 1971
Use my solution, @latent geyser
;compile
local seconds = 70 -- 1:10
for secondsLeft = seconds, 0, -1 do
print(string.format("%d:%02d", math.floor(secondsLeft / 60), secondsLeft % 60))
-- The result of this format-string should be assigned to your TextLabel
-- task.wait(1)
end
1:10
1:09
1:08
1:07
1:06
1:05
1:04
1:03
1:02
1:01
1:00
0:59
0:58
0:57
0:56
0:55
0:54
0:53
0:52
0:51
0:50
0:49
0:48
0:47
0:46
0:45
0:44
0:43
0:42
0:41
0:40
0:39
0:38
0:37
0:36
0:35
0:34
0:33
0:32
0:31
0:30
0:29
0:28
0:27
0:26
0:25
0:24
0:23
0:22
0:21
Simple and intuitive, no overhead
i agree use his solution
;compile
local seconds = 70 -- 1:10
for secondsLeft = seconds, 0, -1 do
print(string.format("%d:%02d", secondsLeft / 60, secondsLeft % 60))
-- The result of this format-string should be assigned to your TextLabel
-- task.wait(1)
end
/opt/wandbox/lua-5.4.3/bin/lua: prog.lua:4: bad argument #2 to 'format' (number has no integer representation)
stack traceback:
[C]: in function 'string.format'
prog.lua:4: in main chunk
[C]: in ?
Yeah. You can use "%d" or "%i" in Luau and it wouldn't make a difference. In Lua, both fail to floor the input value
The closest you can get to cross-compatible code is through math.floor
(Seething that Roblox hasn't introduced //)
local seconds = 70 -- 1:10
for secondsLeft = seconds, 0, -1 do
print(string.format("%02d:%02d", secondsLeft / 60, secondsLeft % 60))
-- The result of this format-string should be assigned to your TextLabel
-- task.wait(1)
end
wasnt it in the luau future notes or something
For future updates?
yeah
found it
I did too; looking at it now
;compile
/opt/wandbox/lua-5.4.3/bin/lua: prog.lua:4: bad argument #2 to 'format' (number has no integer representation)
stack traceback:
[C]: in function 'string.format'
prog.lua:4: in main chunk
[C]: in ?
;compile
1:10
1:09
1:08
1:07
1:06
1:05
1:04
1:03
1:02
1:01
1:00
0:59
0:58
0:57
0:56
0:55
0:54
0:53
0:52
0:51
0:50
0:49
0:48
0:47
0:46
0:45
0:44
0:43
0:42
0:41
0:40
0:39
0:38
0:37
0:36
0:35
0:34
0:33
0:32
0:31
0:30
0:29
0:28
0:27
0:26
0:25
0:24
0:23
0:22
0:21
Looks like it's already been implemented. Finally.
this one works so
🤦♂️
for i = IntermissionLength, 0, -1 do
if i == 0 then
print("Game starting")
else
end
else
wait(0.2)
AnnounceE:FireAllClients(os.date("%M:%S", i + 5* 60 * 60))
end
end
;compile
/opt/wandbox/lua-5.4.3/bin/lua: prog.lua:7: 'end' expected (to close 'for' at line 1) near 'else'
woops
for i = IntermissionLength, 0, -1 do
if i == 0 then
print("Game starting")
if #game.Players:GetPlayers() >= 1 then
RS.GameEvents.GameStart:Fire()
else
AnnounceE:FireAllClients("Waiting for players...")
end
else
wait(0.2)
AnnounceE:FireAllClients(os.date("%M:%S", i + 5* 60 * 60))
end
```
;compile
/opt/wandbox/lua-5.4.3/bin/lua: prog.lua:13: 'end' expected (to close 'for' at line 1) near <eof>
Seriously, you're using an overcomplicated solution that does more work than is needed, @latent geyser
Anyone who looks at that code will be confused, lol
This is standard
it still works
That is the single-most stupid mentality one could have when it comes to coding
but it works