Advertisement
Shurhaian

ComputerCraft automatic music player

Mar 8th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. -- SkunkWorks Logistics
  2. -- Automatic music-disc player
  3.  
  4. diskSide = "bottom" -- Disk drive location for this install
  5. version = "1.0"
  6. print("SkunkWorks Logistics")
  7. print("Music Player v"..version)
  8.  
  9. print("Checking for disk...")
  10.  
  11. while true do
  12.     if disk.isPresent(diskSide) then
  13.         if disk.hasAudio(diskSide) then
  14.             print("Audio disc found.") -- Note that the official name of these discs uses a c, not a k, while CC's uses a k
  15.             print("Now playing: \""..disk.getLabel(diskSide).."\" Enjoy!")
  16.             disk.playAudio(diskSide)
  17.         else
  18.             print("Data disk found. Please eject this disk and insert an audio disc.")
  19.         end
  20.         os.pullEvent("disk_eject") -- Wait for disk to eject - rather than spinning through the loop if a data disk is in
  21.         print("Disk ejected.")
  22.     else
  23.         print("Waiting for disc...")
  24.         os.pullEvent("disk") -- Wait for a disk to be inserted
  25.         print("Disk inserted.")
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement