Guest

Untitled

By: a guest on Feb 19th, 2012  |  syntax: Lua  |  size: 1.49 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. pcall(magic.enable)
  2. -- load song into table
  3. args = { ... }
  4. notes = {}
  5. file = io.open(args[1], "r")
  6. x = 1
  7. while true do
  8. note = file:read()
  9. if note == nil then break end
  10. table.insert(notes,note)
  11. end
  12.  
  13. tempo = string.sub(notes[1], 2)
  14. tempo = tempo / 100
  15. tempo = .2 - tempo
  16.  
  17. currentoctave = 0
  18. currentnote = 0
  19. currentinstrument = 0
  20. px,py,pz = magic.getPlayerLoc()
  21. for x = 2, #notes do
  22. if notes[x] == "BG" then currentinstrument = 4
  23. elseif notes[x] == "CS" then currentinstrument = 3
  24. elseif notes[x] == "SD" then currentinstrument = 2
  25. elseif notes[x] == "BD" then currentinstrument = 1
  26. elseif notes[x] == "PI" then currentinstrument = 0
  27. elseif notes[x] == "1" then currentoctave = 0
  28. elseif notes[x] == "2" then currentoctave = 1
  29. elseif notes[x] == "3" then currentoctave = 2
  30. elseif notes[x] == "." then sleep(tempo)
  31. else
  32. if notes[x] == "F#" then currentnote = 0 end
  33. if notes[x] == "G"  then currentnote = 1 end
  34. if notes[x] == "G#" then currentnote = 2 end
  35. if notes[x] == "A"  then currentnote = 3 end
  36. if notes[x] == "A#" then currentnote = 4 end
  37. if notes[x] == "B"  then currentnote = 5 end
  38. if notes[x] == "C" then currentnote = 6 end
  39. if notes[x] == "C#" then currentnote = 7 end
  40. if notes[x] == "D" then currentnote = 8 end
  41. if notes[x] == "D#" then currentnote = 9 end
  42. if notes[x] == "E" then currentnote = 10 end
  43. if notes[x] == "F" then currentnote = 11 end
  44. currentnote = currentnote + (currentoctave * 12)
  45. magic.playSound(px,py,pz,currentinstrument,currentnote, true)
  46. end
  47. end