Advertisement
SuPeRMiNoR3

[ComputerCraft] Multitasking Test

Jan 13th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. function main()
  2. parallel.waitForAll(mon1, mon2, input)
  3. end
  4.  
  5. function input()
  6. sleep(5)
  7. while true do
  8. clear()
  9. write("Waiting for input: ")
  10. input = read()
  11. clear()
  12. print("You entered: "..input)
  13. sleep(5)
  14. end
  15. end
  16.  
  17. function clear()
  18. term.clear()
  19. term.setCursorPos(1,1)
  20. end
  21.  
  22. function mon1()
  23. local mon = peripheral.wrap("right")
  24. while true do
  25. mon.clear()
  26. mon.setCursorPos(1,1)
  27. mon.write("World Time: ")
  28. mon.write(os.clock())
  29. sleep(0.1)
  30. end
  31. end
  32.  
  33. function mon2()
  34. local mon = peripheral.wrap("left")
  35. while true do
  36. mon.clear()
  37. mon.setCursorPos(1,1)
  38. mon.write("Computer Time: ")
  39. mon.write(os.time())
  40. sleep(0.1)
  41. end
  42. end
  43.  
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement