Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to convert this?

Asked by 8 years ago

How do i convert this into this 'There is 1:00 time left!' and count down from there?

for i = 60, 0, -1 do
Time = 'There is '..i..' time left!'
wait(1)
end

1 answer

Log in to vote
1
Answered by 8 years ago

So you want to make a clock. First we will look at some methods that will help us with this. % mod or modulus is an operator that returns the remainder of number1 divided by nuber2 so ...

10%3 = 1 

this is because 10 goes into 3 perfectly 3 times then has 1 left over so this returns 1. SO how do we implement this well we simply use this to find the number of seconds left in the minute. so our code now would look something like this

for i = 60, 0, -1 do
    Time = "there is " .. tostring(math.floor(i / 60)) .. ":" .. tostring(i % 60) .. "Seconds left"
    wait(1)
end

So that code did 2 things first we found the minute by dividing the number of seconds by 60 and rounding that number down. Don't confuse this with the % operator because they are not the same thing. The first operation returns how many times i can evenly be divided by 60 while the second operation returns how far i is past the interval of 60.

hope this helped

0
Thank you so much, I've been trying to do this in forever. But without sources to learn i cant do anything really. Thanks again! UltraUnitMode 419 — 8y
0
Thank you so much, I've been trying to do this in forever. But without sources to learn i cant do anything really. Thanks again! UltraUnitMode 419 — 8y
0
you're welcome glad that i could help ProfessorSev 220 — 8y
Ad

Answer this question