Advertisement
neonerz

music

Feb 18th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. printerSide = "front"
  2. ejectRedstoneSide = "left"
  3. recordSide = "bottom"
  4.  
  5. function play(dside,rrside,acolor)
  6.         if value2 == "white" then theColor=1
  7.         elseif value2 == "orange" then theColor=2
  8.         elseif value2 == "magenta" then theColor=4
  9.         elseif value2 == "lightblue" then theColor=8
  10.         elseif value2 == "yellow" then theColor=16
  11.         elseif value2 == "lime" then theColor=32
  12.         elseif value2 == "pink" then theColor=64
  13.         elseif value2 == "gray" then theColor=128
  14.         elseif value2 == "lightgray" then theColor=256
  15.         elseif value2 == "cyan" then theColor=512
  16.         elseif value2 == "purple" then theColor=1024
  17.         elseif value2 == "blue" then theColor=2048
  18.         elseif value2 == "brown" then theColor=4096
  19.         elseif value2 == "green" then theColor=8192
  20.         elseif value2 == "red" then theColor=16384
  21.         elseif value2 == "black" then theColor=32768
  22.         else print("Error: color out of range") return
  23.         end
  24.         print("loading track")
  25.         redstone.setBundledOutput(rrside, theColor)
  26.         sleep(1)
  27.         redstone.setBundledOutput(rrside, 0)
  28.         while not disk.isPresent(dside) do
  29.                 sleep(.5)
  30.         end    
  31.         print("track loaded, playing track")
  32.         disk.playAudio(dside)
  33. end
  34.  
  35. function stop(dside)
  36.         print("stopping track")
  37.         disk.stopAudio(dside)
  38. end
  39.  
  40. function eject(drside)
  41.         print("ejecting track")
  42.         redstone.setOutput(drside, true)
  43.         sleep(1)
  44.         redstone.setOutput(drside, false)
  45. end
  46.  
  47.  
  48.  
  49.  
  50. local tArgs = { ... }
  51.  
  52. h = fs.open("music-colors","r")
  53. line = tostring(h.readLine())
  54.  
  55.  
  56.  
  57. if tArgs[1] == "play" then
  58.     while line ~= nil do
  59.         value1,value2 = string.match(line,"(.+)%s?:%s?(.+)")
  60.         if value1 == tArgs[2] then
  61.             print("You want to play "..value1)
  62.             print("It is on the "..value2.." line")
  63.             play(printerSide,recordSide,value2)
  64.             return
  65.         end
  66.         line = h.readLine()
  67.     end
  68.     print ("The disk "..tArgs[2].." isn't loaded")    
  69. end
  70.  
  71. if tArgs[1] == "stop" then
  72.         stop(printerSide)
  73. end
  74.  
  75. if tArgs[1] == "eject" then
  76.         eject(ejectRedstoneSide)
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement