rules54

Untitled

Jul 1st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. disk = {...}
  2. titles = {...}
  3. chat = peripheral.wrap("front")
  4. drive = peripheral.wrap("bottom")
  5. loopValue = true
  6.  
  7. function title(var, var2, var4)
  8. if string.find(var, var2) ~= nil then
  9. table.insert(titles, var4)
  10. end
  11. end
  12.  
  13. print("Running Remote DJ Program")
  14. print("Type, 'record help' in chat for commands")
  15.  
  16. print("Retreiving disk titles..")
  17. turtle.select(1) turtle.suckDown()
  18. for i=1,16 do
  19. if turtle.getItemCount(i) == 1 then
  20. turtle.select(i)
  21. turtle.dropDown()
  22. table.insert(disk, drive.getAudioTitle())
  23. turtle.suckDown()
  24. end
  25. end
  26. print("Reformatting disk titles..")
  27.  
  28. for i=1, #disk do
  29. title(disk[i],"13","13")
  30. title(disk[i],"cat","cat")
  31. title(disk[i],"blocks","blocks")
  32. title(disk[i],"chirp","chirp")
  33. title(disk[i],"far","far")
  34. title(disk[i],"mall","mall")
  35. title(disk[i],"mellohi","mellohi")
  36. title(disk[i],"stal","stal")
  37. title(disk[i],"strad","strad")
  38. title(disk[i],"ward","ward")
  39. title(disk[i],"11", "11")
  40. title(disk[i],"wait", "wait")
  41. title(disk[i],"pg.wantyougone","Want You Gone")
  42. title(disk[i],"pg.stillalive","Still Alive")
  43. end
  44.  
  45.  
  46. diskString = ""
  47. for i=1, #titles-1 do
  48. diskString = diskString.. i..": "..titles[i]..", "
  49. end
  50.  
  51. diskString = diskString..#titles..": "..titles[#titles]
  52.  
  53. print("Formatted titles into string:")
  54. print(diskString)
  55. print("Beginning loop.")
  56.  
  57.  
  58. while loopValue do
  59. event, player, msg = os.pullEvent("chat")
  60. message = string.lower(msg)
  61. if string.find(message, "record list") ~= nil then
  62. os.sleep(.1)
  63. chat.tell(player, diskString)
  64. elseif string.find(message,"record play") ~= nil then
  65. turtle.suckDown()
  66. for i=1, 16 do
  67. if string.find(message,i) ~= nil then
  68. turtle.select(i) turtle.dropDown()
  69. drive.playAudio()
  70. end
  71. end
  72. elseif string.find(message, "record stop") ~= nil then
  73. turtle.suckDown()
  74. elseif string.find(message, "record shuffle") ~= nil then
  75. turtle.suckDown() turtle.select(math.random(1,#disk))
  76. turtle.dropDown() drive.playAudio()
  77. elseif string.find(message, "record reload") ~= nil then
  78. os.reboot()
  79. elseif string.find(message, "record help") ~= nil then
  80. os.sleep(.1)
  81. chat.tell(player, "Available commands: (all prefixed with 'record')")
  82. chat.tell(player, "Help, List, Play <disk number>, Stop, Shuffle, Reload.")
  83. end
  84. end
  85.  
  86.  
  87.  
  88. -- for i=1, #disk do print(disk[i]) end
Advertisement
Add Comment
Please, Sign In to add comment