Alyssa

Song player

Aug 20th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. -- Music/song player v3
  2. --Made with some help from freak
  3. -- Dangranos helped with v2, which this is
  4. -- based off
  5. -- All of this made (An re-wrote) by
  6. -- Luker (luker2009)
  7. args = {...}
  8. side = args[2] or "bottom"
  9. run = true
  10. if args[1] == nil then
  11.  print("Please put a file to play!")
  12.  run = false
  13. else
  14.  file = args[1]
  15. end
  16. inb = peripheral.wrap(side)
  17. counter = fs.open(file, "r")
  18. count = 1
  19. linec = counter.readLine()
  20. while linec do
  21.  linec = counter.readLine()
  22.  count = count +1
  23. end
  24. lines = count
  25. a = 0
  26. song = fs.open(file, "r")
  27. for i = 1, lines do
  28.  a = a+1
  29.   if a == 1 then
  30.    instr = tonumber(song.readLine())
  31.   elseif a == 2 then
  32.    note = tonumber(song.readLine())
  33.   else
  34.    wait = tonumber(song.readLine())
  35.    sleep(wait)
  36.    inb.playNote(instr,note)
  37.    a = 0
  38.   end
  39. end
  40. song.close()
Advertisement
Add Comment
Please, Sign In to add comment