Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. term.clear()
  2.  
  3. networked=false
  4.  
  5. if peripheral.isPresent("left") then
  6. if peripheral.getType("left") == "modem" then
  7. networked=true
  8. end
  9. end
  10.  
  11. function findPeripheral()
  12. local dd = false
  13. local mon = false
  14. if peripheral.isPresent("right") then
  15. if peripheral.getType("right") == "drive" then
  16. doit=true
  17. end
  18. end
  19. if peripheral.isPresent("top") then
  20. if peripheral.getType("top") == "monitor" then
  21. mon=true
  22. end
  23. end
  24. if mon and doit then
  25. return true
  26. end
  27. end
  28.  
  29. function playMusic()
  30. if findPeripheral() then
  31. if disk.hasAudio("right") then
  32. disp = peripheral.wrap("top")
  33. name = disk.getAudioTitle("right")
  34. disk.playAudio("right")
  35.  
  36. local xx,yy = disp.getSize()
  37. xx = (xx/2)
  38. local offX = string.len(name)/2
  39.  
  40. disp.clear()
  41. disp.setCursorPos(xx-offX,yy/2)
  42. disp.write(name)
  43. else
  44. term.write("no disk found!")
  45. end
  46. end
  47. end
  48.  
  49. if networked then
  50.  
  51. rednet.open("left")
  52. term.write("Networked mode - waiting for signal from client...")
  53. local thispc = os.getComputerID()
  54. term.write("listening on id: "..thispc)
  55. while true do
  56. local id,msg = rednet.receive()
  57. if id == 19 then
  58. if msg == "play" then
  59. playMusic()
  60. end
  61. if msg == "stop" then
  62. disk.stopAudio("right")
  63. end
  64. if msg == "eject" then
  65. disk.stopAudio("right")
  66. disk.eject("right")
  67. end
  68. if msg == "restart" then
  69. disk.stopAudio("right")
  70. disk.playAudio("right")
  71. end
  72. end
  73. sleep(1)
  74. end
  75. else
  76. playMusic()
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement