Posted 14 November 2015 - 03:39 AM
function printSecondsAsDaysHoursMinutesSeconds(s)
local calculate = 1
local seconds = tonumber(s)
while seconds > 0 do
if calculate == 1 then
local minutes = math.floor(seconds / 60)
local seconds = seconds - minutes * 60
local hours = math.floor(minutes / 60)
local minutesHolder = hours * 60
local minutes = minutes - minutesHolder
local days = math.floor(hours / 24)
local hours = hours - days * 24
local seconds = tonumber(seconds)
local minutes = tonumber(minutes)
local hours = tonumber(hours)
local days = tonumber(days)
local calculate = 0
end
sleep(1)
local seconds = seconds - 1
term.clear()
term.setCursorPos(1,1)
print(days..":"..hours..":"..minutes..":"..seconds) < – line 31
if seconds == 0 and minutes > 0 then
local seconds = seconds + 59
local minutes = minutes - 1
elseif minutes == 0 and hours > 0 then
local minutes = minutes + 59
local hours = hours - 1
elseif hours == 0 and days > 0 then
local hours = hours + 24
local days = days - 1
elseif days == 0 and hours == 0 and minutes == 0 and seconds == 0 then
term.clear()
term.setCursorPos(1,1)
print("Countdown Complete!")
sleep(3)
end
end
end
print("Seconds?")
local seconds = read()
printSecondsAsDaysHoursMinutesSeconds(seconds)
its saying im trying to concatenate nil and string, even when ive tonumbered all the numbers.
local calculate = 1
local seconds = tonumber(s)
while seconds > 0 do
if calculate == 1 then
local minutes = math.floor(seconds / 60)
local seconds = seconds - minutes * 60
local hours = math.floor(minutes / 60)
local minutesHolder = hours * 60
local minutes = minutes - minutesHolder
local days = math.floor(hours / 24)
local hours = hours - days * 24
local seconds = tonumber(seconds)
local minutes = tonumber(minutes)
local hours = tonumber(hours)
local days = tonumber(days)
local calculate = 0
end
sleep(1)
local seconds = seconds - 1
term.clear()
term.setCursorPos(1,1)
print(days..":"..hours..":"..minutes..":"..seconds) < – line 31
if seconds == 0 and minutes > 0 then
local seconds = seconds + 59
local minutes = minutes - 1
elseif minutes == 0 and hours > 0 then
local minutes = minutes + 59
local hours = hours - 1
elseif hours == 0 and days > 0 then
local hours = hours + 24
local days = days - 1
elseif days == 0 and hours == 0 and minutes == 0 and seconds == 0 then
term.clear()
term.setCursorPos(1,1)
print("Countdown Complete!")
sleep(3)
end
end
end
print("Seconds?")
local seconds = read()
printSecondsAsDaysHoursMinutesSeconds(seconds)
its saying im trying to concatenate nil and string, even when ive tonumbered all the numbers.