Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[made by ezra3131]]--
- local side = "right" --kant van monitor
- local tekst = "moving text program" --tekst om te laten zien
- local speed = 4 -- hoe hoger, hoe sneller
- local scale = 5 -- tekstgrootte
- local yPos = 1 -- plaats Y-as
- ---------------------------------------------
- local m = peripheral.wrap(side)
- m.setTextScale(scale)
- local sizeX,sizeY = m.getSize()
- local xPos = sizeX
- local printText = function()
- while true do
- m.clear()
- m.setCursorPos(xPos,yPos)
- m.write(tekst)
- if xPos < 1 - string.len(tekst) then
- xPos = sizeX
- else
- xPos = xPos - 1
- end
- os.sleep(1 / speed)
- end
- end
- --clock program
- local time = http.get("http://www.timeapi.org/cet/now").readAll()
- time = string.sub(time, 12, 19)
- local m = peripheral.wrap("top")
- m.setCursorPos(1,2)
- local hours = time
- hours = tonumber(string.sub(hours, 1, 2))
- local minutes = time
- minutes = tonumber(string.sub(minutes, 4,5))
- local seconds = time
- seconds = tonumber(string.sub(seconds, 7,8))
- local addHour = function()
- hours = hours + 1
- if hours >= 24 then
- hours = hours - 24
- end
- end
- local addMinute = function()
- minutes = minutes + 1
- if minutes >= 60 then
- minutes = minutes - 60
- addHour()
- end
- end
- local addSecond = function()
- seconds = seconds + 1
- if seconds >= 60 then
- seconds = seconds - 60
- addMinute()
- end
- end
- local printTime = function()
- m.clear()
- if hours < 10 then
- m.setCursorPos(1,2)
- m.write(0)
- m.setCursorPos(2,2)
- m.write(hours)
- else
- m.setCursorPos(1,2)
- m.write(hours)
- end
- m.setCursorPos(3,2)
- m.write(":")
- if minutes < 10 then
- m.setCursorPos(4,2)
- m.write(0)
- m.setCursorPos(5,2)
- m.write(minutes)
- else
- m.setCursorPos(4,2)
- m.write(minutes)
- end
- m.setCursorPos(6,2)
- m.write(":")
- if seconds < 10 then
- m.setCursorPos(7,2)
- m.write(0)
- m.setCursorPos(8,2)
- m.write(seconds)
- else
- m.setCursorPos(7,2)
- m.write(seconds)
- end
- end
- local printClock = function()
- while true do
- addSecond()
- printTime()
- os.sleep(1)
- end
- end
- parallel.waitForAll(printText, printClock)
Advertisement
Add Comment
Please, Sign In to add comment