Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local d = {}
- for i, name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == "drive" then
- table.insert(d, name)
- end
- end
- if table.getn(d) < 1 then
- print("No drives found! Exiting...")
- end
- for i, name in pairs(d) do
- if peripheral.call(name, "hasAudio") then
- print(string.format("Drive %i %q: %q", i, name, peripheral.call(name, "getAudioTitle")))
- else
- print(string.format("Drive %i %q: %s", i, name, "NO DISC"))
- end
- end
- local num = false
- while not num do
- io.write("Play Disc: ")
- num = tonumber(io.read())
- if not num or num < 1 or num > table.getn(d) then print("Invalid input!") end
- end
- print(string.format("Playing %q now!", peripheral.call(d[num], "getAudioTitle")))
- peripheral.call(d[num], "playAudio")
- local cmd = ""
- while cmd ~= "exit" and cmd ~= "stop" do
- print(string.format("Enter %q or %q to quit.", "exit", "stop"))
- cmd = io.read()
- end
- peripheral.call(d[num], "stopAudio")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement