SirSheepe

Untitled

Oct 7th, 2018
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local song = [[
  2. f5 e5 d5 d5 e5 - - - - -
  3. g4 f5 e5 d5 d5 - ` e5 c5 - ` d5 g4 - - - - -
  4. d5 ` e5 f5 - ` d5 b4 c5 d5 - - g4 g4 e5 - - - - -
  5. g4 f5 e5 d5 d5 e5 - - - - -
  6. g4 f5 e5 d5 d5 - ` e5 c5 - ` d5 g4 - - - - -
  7. d5 ` e5 f5 - ` d5 b4 c5 d5 ` g4 c5 d5 ` d#5 d5 c5 a#4 - -
  8. c5 c#5 a#4 d#5 d5 g4 g4 a#4 g4 a#4 a#4 a#4
  9. ]]
  10.  
  11. local speaker = peripheral.find("speaker")
  12.  
  13. local notes = {
  14. ["f#4"] = 0,
  15. ["g4"] = 1,
  16. ["g#4"] = 2,
  17. ["a4"] = 3,
  18. ["a#4"] = 4,
  19. ["b4"] = 5,
  20. ["c5"] = 6,
  21. ["c#5"] = 7,
  22. ["d5"] = 8,
  23. ["d#5"] = 9,
  24. ["e5"] = 10,
  25. ["f5"] = 11,
  26. ["f#5"] = 12,
  27. ["g5"] = 13,
  28. ["g#5"] = 14,
  29. ["a5"] = 15,
  30. ["a#5"] = 16,
  31. ["b5"] = 17,
  32. ["c6"] = 18,
  33. ["c#6"] = 19,
  34. ["d6"] = 20,
  35. ["d#6"] = 21,
  36. ["e6"] = 22,
  37. ["f6"] = 23,
  38. ["f#6"] = 24,
  39. }
  40.  
  41. for note in song:gmatch("[^%s]+") do
  42. if note == "-" then
  43. sleep(0.1)
  44. elseif note == "`" then
  45. sleep(0.05)
  46. else
  47. speaker.playNote("xylophone", 1, notes[note])
  48. end
  49. sleep(0.15)
  50. end
RAW Paste Data