Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local song = [[
- f5 e5 d5 d5 e5 - - - - -
- g4 f5 e5 d5 d5 - ` e5 c5 - ` d5 g4 - - - - -
- d5 ` e5 f5 - ` d5 b4 c5 d5 - - g4 g4 e5 - - - - -
- g4 f5 e5 d5 d5 e5 - - - - -
- g4 f5 e5 d5 d5 - ` e5 c5 - ` d5 g4 - - - - -
- d5 ` e5 f5 - ` d5 b4 c5 d5 ` g4 c5 d5 ` d#5 d5 c5 a#4 - -
- c5 c#5 a#4 d#5 d5 g4 g4 a#4 g4 a#4 a#4 a#4
- ]]
- local speaker = peripheral.find("speaker")
- local notes = {
- ["f#4"] = 0,
- ["g4"] = 1,
- ["g#4"] = 2,
- ["a4"] = 3,
- ["a#4"] = 4,
- ["b4"] = 5,
- ["c5"] = 6,
- ["c#5"] = 7,
- ["d5"] = 8,
- ["d#5"] = 9,
- ["e5"] = 10,
- ["f5"] = 11,
- ["f#5"] = 12,
- ["g5"] = 13,
- ["g#5"] = 14,
- ["a5"] = 15,
- ["a#5"] = 16,
- ["b5"] = 17,
- ["c6"] = 18,
- ["c#6"] = 19,
- ["d6"] = 20,
- ["d#6"] = 21,
- ["e6"] = 22,
- ["f6"] = 23,
- ["f#6"] = 24,
- }
- for note in song:gmatch("[^%s]+") do
- if note == "-" then
- sleep(0.1)
- elseif note == "`" then
- sleep(0.05)
- else
- speaker.playNote("xylophone", 1, notes[note])
- end
- sleep(0.15)
- end
RAW Paste Data