--giant clock--
local sSide = {
"left",
"right",
"top",
"bottom",
"back",
"front"
}
--peripheral check
for i=1,#sSide do
if peripheral.isPresent(sSide) then
if peripheral.getType(sSide) == "monitor" then mon = peripheral.wrap(sSide)
elseif peripheral.getType(sSide)==nil then
error("No peripheral attached")
end
end
end
--variables
local digits = {}
digits[0]={" ___ ",
" / _ \\ ",
" | | | |",
" | | | |",
" | |_| |",
" \\___/ "}
digits[1]={" __ ",
" /_ | ",
" | | ",
" | | ",
" | | ",
" |_| "}
digits[2]={" ___ ",
" |__ \\ ",
" ) | ",
" / / ",
" / /_ ",
" |____| "}
digits[3]={" ____ ",
" |___ \\ ",
" __) |",
" |__ < ",
" ___) |",
" |____/ "}
digits[4]={" _ _ ",
"| || | ",
"| || |_ ",
"|__ _|",
" | | ",
" |_| "}
digits[5]={" _____ ",
" | ____|",
" | |__ ",
" |___ \\ ",
" ___) |",
" |____/ "}
digits[6]={" __ ",
" / / ",
" / /_ ",
" | '_ \\ ",
" | (_) |",
" \\___/ "}
digits[7]={" ______ ",
"|____ |",
" / / ",
" / / ",
" / / ",
" /_/ "}
digits[8]={" ___ ",
" / _ \\ ",
" | (_) |",
" > _ < ",
" | (_) |",
" \\___/ "}
digits[9]={" ___ ",
" / _ \\ ",
" | (_) |",
" \\__, |",
" / / ",
" /_/ "}
digits[10]={" ___ ",
" / _ \\ ",
" | | | |",
" | | | |",
" | |_| |",
" \\___/ "}
digits[11]={" __ ",
" /_ | ",
" | | ",
" | | ",
" | | ",
" |_| "}
digits[12]={" ___ ",
" |__ \\ ",
" ) | ",
" / / ",
" / /_ ",
" |____| "}
local colon = {
" ",
" _ ",
"(_)",
" ",
" _ ",
"(_)"
}
local am = {
" ___ ___ ___ ",
" / \\ | \\/ | ",
" / ^ \\ | \\ / | ",
" / /_\\ \\ | |\\/| | ",
" / _____ \\ | | | | ",
"/__/ \\__\\ |__| |__| "
}
local pm = {
" ______ ___ ___ ",
"| _ \\ | \\/ | ",
"| |_) | | \\ / | ",
"| ___/ | |\\/| | ",
"| | | | | | ",
"|__| |__| |__| "
}
--functions
function digits12(h,m)
mon.clear()
--hours
if h == 0 then
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[1])
mon.setCursorPos(11,i)
mon.write(digits[2])
end
elseif h < 12 then
if h < 10 and h >= 1 then
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[0])
mon.setCursorPos(11,i)
mon.write(digits[h])
end
elseif h >= 10 and h < 20 then
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[1])
mon.setCursorPos(11,i)
mon.write(digits[h])
end
end
elseif h == 12 then
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[1])
mon.setCursorPos(11,i)
mon.write(digits[2])
end
elseif h > 12 and h < 24 then
local h = h - 12
if h < 10 then
mon.setCursorPos(1,1)
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[0])
mon.setCursorPos(11,i)
mon.write(digits[h])
end
elseif h >= 10 and h < 20 then
for i = 1,6 do
mon.setCursorPos(1,i)
mon.write(digits[1])
mon.setCursorPos(11,i)
mon.write(digits[h])
end
end
end
--colon
for i = 1,6 do
mon.setCursorPos(20,i)
mon.write(colon)
end
--minutes
if m < 10 then
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[0])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
elseif m >=10 and m < 20 then
local m = m-10
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[1])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
elseif m >=20 and m < 30 then
local m = m-20
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[2])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
elseif m >=30 and m < 40 then
local m = m-30
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[3])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
elseif m >=40 and m < 50 then
local m = m-40
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[4])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
elseif m >=50 then
local m = m-50
for i = 1,6 do
mon.setCursorPos(24,i)
mon.write(digits[5])
mon.setCursorPos(34,i)
mon.write(digits[m])
end
end
if h < 12 then
for i = 1,6 do
mon.setCursorPos(44,i)
mon.write(am)
end
elseif h >= 12 then
for i = 1,6 do
mon.setCursorPos(44,i)
mon.write(pm)
end
end
end
while true do
local MChours = math.floor(os.time())
local MCminutes = math.floor((os.time()-math.floor(os.time()))*60)
digits12(MChours,MCminutes)
sleep(0)
end