Advertisement
Guest User

Edj

a guest
Mar 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. local d = {}
  2. for i, name in pairs(peripheral.getNames()) do
  3.   if peripheral.getType(name) == "drive" then
  4.     table.insert(d, name)
  5.   end
  6. end
  7. if table.getn(d) < 1 then
  8.   print("No drives found! Exiting...")
  9. end
  10. for i, name in pairs(d) do
  11.   if peripheral.call(name, "hasAudio") then
  12.     print(string.format("Drive %i %q: %q", i, name, peripheral.call(name, "getAudioTitle")))
  13.   else
  14.     print(string.format("Drive %i %q: %s", i, name, "NO DISC"))
  15.   end
  16. end
  17. local num = false
  18. while not num do
  19.   io.write("Play Disc: ")
  20.   num = tonumber(io.read())
  21.   if not num or num < 1 or num > table.getn(d) then print("Invalid input!") end
  22. end
  23. print(string.format("Playing %q now!", peripheral.call(d[num], "getAudioTitle")))
  24. peripheral.call(d[num], "playAudio")
  25. local cmd = ""
  26. while cmd ~= "exit" and cmd ~= "stop" do
  27.   print(string.format("Enter %q or %q to quit.", "exit", "stop"))
  28.   cmd = io.read()
  29. end
  30. peripheral.call(d[num], "stopAudio")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement