Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function drawTime()
- local x, y = term.getCursorPos()
- term.setCursorPos(1,1)
- write("It is "..textutils.formatTime(os.time()))
- term.setCursorPos(x, y)
- end
- local timer = os.startTimer(1)
- term.clear()
- while true do
- local sEvt, arg = os.pullEvent()
- if sEvt == "timer" then
- if arg == timer then
- timer = os.startTimer(1)
- drawTime()
- end
- elseif sEvt == "key" or sEvt == "char" then
- term.clear()
- drawTime()
- term.setCursorPos(1,2)
- if arg == keys.down then
- print("you pressed the down key")
- elseif arg == keys.up then
- print("you pressed the up key")
- elseif arg == keys.right then
- print("you pressed the right key")
- elseif arg == keys.left then
- print("you pressed the left key")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement