Guest User

Untitled

a guest
Sep 29th, 2012
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. local mon = peripheral.wrap("top")
  2. local mx, my = mon.getSize()
  3.  
  4. mon.clear()
  5. term.clear()
  6.  
  7. -- This function will return when any key other than ESC is pressed
  8. function waitForEsc()
  9. while true do
  10. local e, key = os.pullEvent("key")
  11. if key ~= 1 then
  12. -- It wasn't escape
  13. return true
  14. end
  15. end
  16. end
  17.  
  18. -- This function actually does the screensaver, and won't return on its own
  19. function screensaver()
  20. while true do
  21. local x = math.random(1,mx)
  22. local y = math.random(1,my)
  23. mon.setCursorPos(x,y)
  24. mon.write("o")
  25. sleep(2)
  26. mon.clear()
  27. sleep(2)
  28. end
  29. end
  30.  
  31. -- Now run both functions
  32. parallel.waitForAny(function() screensaver() end,function() waitForEsc() end)
  33.  
  34. -- Something returned if we got here
  35. term.clear()
  36. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment