Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --giant clock--
- local sSide = {
- "left",
- "right",
- "top",
- "bottom",
- "back",
- "front"
- }
- --peripheral check
- for i=1,#sSide do
- if peripheral.isPresent(sSide[i]) then
- if peripheral.getType(sSide[i]) == "monitor" then mon = peripheral.wrap(sSide[i])
- elseif peripheral.getType(sSide[i])==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+2)
- mon.write(digits[1][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[2][i])
- end
- elseif h < 12 then
- if h < 10 and h >= 1 then
- for i = 1,6 do
- mon.setCursorPos(1,i+2)
- mon.write(digits[0][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[h][i])
- end
- elseif h >= 10 and h < 20 then
- for i = 1,6 do
- mon.setCursorPos(1,i+2)
- mon.write(digits[1][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[h][i])
- end
- end
- elseif h == 12 then
- for i = 1,6 do
- mon.setCursorPos(1,i+2)
- mon.write(digits[1][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[2][i])
- end
- elseif h > 12 and h < 24 then
- local h = h - 12
- if h < 10 then
- mon.setCursorPos(1,3)
- for i = 1,6 do
- mon.setCursorPos(1,i+2)
- mon.write(digits[0][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[h][i])
- end
- elseif h >= 10 and h < 20 then
- for i = 1,6 do
- mon.setCursorPos(1,i+2)
- mon.write(digits[1][i])
- mon.setCursorPos(11,i+2)
- mon.write(digits[h][i])
- end
- end
- end
- --colon
- for i = 1,6 do
- mon.setCursorPos(20,i+2)
- mon.write(colon[i])
- end
- --minutes
- if m < 10 then
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[0][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- elseif m >=10 and m < 20 then
- local m = m-10
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[1][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- elseif m >=20 and m < 30 then
- local m = m-20
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[2][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- elseif m >=30 and m < 40 then
- local m = m-30
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[3][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- elseif m >=40 and m < 50 then
- local m = m-40
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[4][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- elseif m >=50 then
- local m = m-50
- for i = 1,6 do
- mon.setCursorPos(24,i+2)
- mon.write(digits[5][i])
- mon.setCursorPos(34,i+2)
- mon.write(digits[m][i])
- end
- end
- if h < 12 then
- for i = 1,6 do
- mon.setCursorPos(44,i+2)
- mon.write(am[i])
- end
- elseif h >= 12 then
- for i = 1,6 do
- mon.setCursorPos(44,i+2)
- mon.write(pm[i])
- 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
Add Comment
Please, Sign In to add comment