Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("right")
- m.setTextScale(2)
- clockTop = 3
- segLen = 3
- lit = colors.lime
- unlit = colors.green
- function drawLine(stx, sty, len, dir, col)
- m.setBackgroundColor(col)
- m.setCursorPos(stx, sty)
- if dir == "a" or dir == "across" then
- for i = 1, len do
- m.write(" ")
- end
- elseif dir == "d" or dir == "down" then
- for i = 1, len do
- m.write(" ")
- m.setCursorPos(stx, sty + i)
- end
- end
- m.setBackgroundColor(colors.black)
- end
- function sevSeg(stx, seg, col)
- if seg == 1 then
- drawLine(stx + 1, clockTop, segLen, "a", col)
- elseif seg == 2 then
- drawLine(stx, clockTop + 1, segLen, "d", col)
- elseif seg == 3 then
- drawLine(stx + 4, clockTop + 1, segLen, "d", col)
- elseif seg == 4 then
- drawLine(stx + 1, clockTop + 4, segLen, "a", col)
- elseif seg == 5 then
- drawLine(stx, clockTop + 5, segLen, "d", col)
- elseif seg == 6 then
- drawLine(stx + 4, clockTop + 5, segLen, "d", col)
- elseif seg == 7 then
- drawLine(stx + 1, clockTop + 8, segLen, "a", col)
- end
- end
- function drawNum(stx, num, col)
- if num == 0 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 2, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 5, col)
- sevSeg(stx, 6, col)
- sevSeg(stx, 7, col)
- elseif num == 1 then
- sevSeg(stx, 3, col)
- sevSeg(stx, 6, col)
- elseif num == 2 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 5, col)
- sevSeg(stx, 7, col)
- elseif num == 3 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 6, col)
- sevSeg(stx, 7, col)
- elseif num == 4 then
- sevSeg(stx, 2, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 6, col)
- elseif num == 5 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 2, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 6, col)
- sevSeg(stx, 7, col)
- elseif num == 6 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 2, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 5, col)
- sevSeg(stx, 6, col)
- sevSeg(stx, 7, col)
- elseif num == 7 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 6, col)
- elseif num == 8 then
- for i = 1, 7 do
- sevSeg(stx, i, col)
- end
- elseif num == 9 then
- sevSeg(stx, 1, col)
- sevSeg(stx, 2, col)
- sevSeg(stx, 3, col)
- sevSeg(stx, 4, col)
- sevSeg(stx, 6, col)
- sevSeg(stx, 7, col)
- else
- drawLine(stx, clockTop + 3, 1, "a", lit)
- drawLine(stx, clockTop + 6, 1, "a", lit)
- end
- end
- function getTime()
- time = textutils.formatTime(os.time(), true)
- if string.len(time) > 4 then
- ht = string.sub(time, 1, 1)
- hu = string.sub(time, 2, 2)
- mt = string.sub(time, 4, 4)
- mu = string.sub(time, 5, 5)
- else
- ht = 0
- hu = string.sub(time, 1, 1)
- mt = string.sub(time, 3, 3)
- mu = string.sub(time, 4, 4)
- end
- ht = tonumber(ht)
- hu = tonumber(hu)
- mt = tonumber(mt)
- mu = tonumber(mu)
- end
- function display()
- getTime()
- drawNum(3, 8, unlit)
- drawNum(9, 8, unlit)
- drawNum(15, 10, lit)
- drawNum(17, 8, unlit)
- drawNum(23, 8, unlit)
- drawNum(3, ht, lit)
- drawNum(9, hu, lit)
- drawNum(17, mt, lit)
- drawNum(23, mu, lit)
- end
- while true do
- display()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement