Advertisement
superkh

MusicPlayer

Nov 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. rng=true
  2. playing=false
  3. loop=0
  4. term.setBackgroundcolor(colors.black)
  5. term.setTextColor(colors.white)
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. while rng do
  9.   if disk.hasAudio("left") and playing==false then
  10.     loop=0
  11.     n = disk.getAudioTitle("left")
  12.     term.clear()
  13.     if n==nil then n="No Title" end
  14.     term.setCursorPos(15,1)
  15.     term.write("playing "..n)
  16.     disk.playAudio("left")
  17.     playing=true
  18.    elseif playing==true and disk.hasAudio("left") then
  19.      loop=0
  20.      local e,k = os.pullEvent("key")
  21.      if k==keys.w then
  22.       rng=false
  23.       term.clear()
  24.       term.setCursorPos(1,1)
  25.       disk.stopAudio("left")
  26.      elseif k==keys.e then
  27.        disk.eject("left")
  28.        playing=false
  29.        term.clear()
  30.        term.setCursorPos(20,1)
  31.        term.setTextColor(colors.red)
  32.        term.write("ejected")
  33.        term.setTextColor(colors.white)
  34.        disk.stopAudio("left")
  35.        sleep(1)
  36.      elseif k==keys.r then
  37.        disk.stopAudio("left")
  38.        playing=false
  39.      end
  40.    else
  41.      term.clear()
  42.      term.setCursorPos(1,1)
  43.      term.setTextColor(colors.red)
  44.      term.write("No DISK!!")
  45.      term.setTextColor(colors.white)
  46.      sleep(.5)
  47.    end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement