Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local mx, my = mon.getSize()
- mon.clear()
- term.clear()
- -- This function will return when any key other than ESC is pressed
- function waitForEsc()
- while true do
- local e, key = os.pullEvent("key")
- if key ~= 1 then
- -- It wasn't escape
- return true
- end
- end
- end
- -- This function actually does the screensaver, and won't return on its own
- function screensaver()
- while true do
- local x = math.random(1,mx)
- local y = math.random(1,my)
- mon.setCursorPos(x,y)
- mon.write("o")
- sleep(2)
- mon.clear()
- sleep(2)
- end
- end
- -- Now run both functions
- parallel.waitForAny(function() screensaver() end,function() waitForEsc() end)
- -- Something returned if we got here
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment