Posted 31 October 2015 - 04:23 PM
Hello i got again problem.
Check time.
When time is more than 10 all behave good but if there are less than 10 min time moves one space left and makes dot at the end.
Dot - i made as function but if i remove this function then at the end apears "0"
How i can fix it ? at least remove this "0"
Photos:
print("Minutes?") –only need minutes
write("-> ")
minute = tonumber(read()) –input directly as number(avoid string)
print("Seconds") –only need minutes
write("-> ")
sec = tonumber(read()) –input directly as number(avoid string)
print("TIme added, press button to start countdown")
local j = sec –declare seconds variable
local i = minute —declare minutes variable
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
os.pullEvent("redstone")
if rs.getInput("left") then
rs.setOutput("right",true)
repeat
if i > 0 then
if j > 0 then
j = j - 1
else
j = 59
i = i - 1
end
else
if j > 0 then
j = j - 1
else
done = true
end
end
if j > 9 then
sec = j
else
sec = "0"..j
end
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
until j == 0 and i == 0
mon.setCursorPos(8,3)
mon.write("1")
rs.setOutput("right",true) – trigger redstone output
sleep(1)
end
Check time.
When time is more than 10 all behave good but if there are less than 10 min time moves one space left and makes dot at the end.
Dot - i made as function but if i remove this function then at the end apears "0"
How i can fix it ? at least remove this "0"
Photos:
Spoiler
print("Set countdown to game") –only need minutesprint("Minutes?") –only need minutes
write("-> ")
minute = tonumber(read()) –input directly as number(avoid string)
print("Seconds") –only need minutes
write("-> ")
sec = tonumber(read()) –input directly as number(avoid string)
print("TIme added, press button to start countdown")
local j = sec –declare seconds variable
local i = minute —declare minutes variable
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
os.pullEvent("redstone")
if rs.getInput("left") then
rs.setOutput("right",true)
repeat
if i > 0 then
if j > 0 then
j = j - 1
else
j = 59
i = i - 1
end
else
if j > 0 then
j = j - 1
else
done = true
end
end
if j > 9 then
sec = j
else
sec = "0"..j
end
min = i
sleep(1)
–Returning Results
mon.setTextScale(5)
mon.setCursorPos(7,5)
mon.write(min..":"..sec)
until j == 0 and i == 0
mon.setCursorPos(8,3)
mon.write("1")
rs.setOutput("right",true) – trigger redstone output
sleep(1)
end
Edited on 31 October 2015 - 03:24 PM