Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local NoteBlock = peripheral.wrap("right")
- local NBBASS = peripheral.wrap("note_block_9")
- local NBSNARE = peripheral.wrap("note_block_8")
- local NBPIANO1 = peripheral.wrap("note_block_10")
- local NBPIANO2 = peripheral.wrap("note_block_11")
- local NBPIANO3 = peripheral.wrap("note_block_12")
- function getNotes (inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- local notesBass = getNotes("X", "-")
- local notesSnare = getNotes("X", "-")
- local notesPiano1 = getNotes("18-#2-16-#2-15-#2-11-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-16-#2-16-#2-16-#2-16-#2-20-#2-20-#2-20-#2-20-#2-18-#2-18-#2-18-#2-18-#2-23-#2-23-#2-23-#2-23-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-18-#2-16-#2-15-#2-11-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-#2-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-20-#2-18-#6-16-#6-15-#6-15-#2-15-#2-18-#6-16-15-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-13-#6-13-#2-16-#2-15-#2-16-#2-15-#2-16-#2-16-#2-16-#2-16-#2-20-#2-20-#2-20-#2-20-#2-18-#2-18-#2-18-#2-18-#2-23-#2-23-#2-23-#2-23-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-#2-13-X", "-")
- local notesPiano2 = getNotes("#22-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#40-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-1-#4-1-#8-9-#4-9-#8-9-#4-9-#8-11-#4-11-#8-11-#4-11-#8-1-#4-1-#8-1-#4-1-X", "-")
- local notesPiano3 = getNotes("X", "-")
- for _,v in pairs(notesBass) do
- print(v)
- end
- local nbBass = 1
- local nbSnare = 1
- local nbPiano1 = 1
- local nbPiano2 = 1
- local nbPiano3 = 1
- local TFBassBreak = false
- local TFSnareBreak = false
- local TFPiano1Break = false
- local TFPiano2Break = false
- local TFPiano3Break = false
- local BASS = true
- local SNARE = true
- local PIANO1 = true
- local PIANO2 = true
- local PIANO3 = true
- local BassBreakNB = 0
- local SnareBreakNB = 0
- local Piano1BreakNB = 0
- local Piano2BreakNB = 0
- local Piano3BreakNB = 0
- local playBass = 0
- local playSnare = 0
- local playPiano1 = 0
- local playPiano2 = 0
- local playPiano3 = 0
- while true do
- --BASS
- if BASS == true then
- playBass = notesBass[nbBass]
- if TFBassBreak == true then
- BassBreakNB = BassBreakNB + 1
- if BassBreakNB == BassBreak then
- TFBassBreak = false
- BassBreakNB = 0
- nbBass = nbBass + 1
- end
- else
- if string.sub(playBass, 1, 1) == "#" then
- BassBreak = tonumber(string.sub(playBass, 2))
- TFBassBreak = true
- else
- if playBass == "/" then
- term.write(playBass.."\n")
- nbBass = nbBass + 1
- else
- if playBass == "X" then
- BASS = false
- else
- if playBass == "R" then
- nbBass = 1
- else
- term.write(playBass.."\n")
- NBBASS.setPitch(playBass)
- NBBASS.triggerNote()
- nbBass = nbBass + 1
- end
- end
- end
- end
- end
- end
- --SNARE
- if SNARE == true then
- playSnare = notesSnare[nbSnare]
- if TFSnareBreak == true then
- SnareBreakNB = SnareBreakNB + 1
- if SnareBreakNB == SnareBreak then
- TFSnareBreak = false
- SnareBreakNB = 0
- nbSnare = nbSnare + 1
- end
- else
- if string.sub(playSnare, 1, 1) == "#" then
- SnareBreak = tonumber(string.sub(playSnare, 2))
- TFSnareBreak = true
- else
- if playSnare == "/" then
- term.write(playSnare.."\n")
- nbSnare = nbSnare + 1
- else
- if playSnare == "X" then
- SNARE = false
- else
- if playSnare == "R" then
- nbSnare = 1
- else
- term.write(playSnare.."\n")
- NBSNARE.setPitch(playSnare)
- NBSNARE.triggerNote()
- nbSnare = nbSnare + 1
- end
- end
- end
- end
- end
- end
- --PIANO
- --#1
- if PIANO1 == true then
- playPiano1 = notesPiano1[nbPiano1]
- if TFPiano1Break == true then
- Piano1BreakNB = Piano1BreakNB + 1
- if Piano1BreakNB == Piano1Break then
- TFPiano1Break = false
- Piano1BreakNB = 0
- nbPiano1 = nbPiano1 + 1
- end
- else
- if string.sub(playPiano1, 1, 1) == "#" then
- Piano1Break = tonumber(string.sub(playPiano1, 2))
- TFPiano1Break = true
- else
- if playPiano1 == "/" then
- term.write(playPiano1.."\n")
- nbPiano1 = nbPiano1 + 1
- else
- if playPiano1 == "X" then
- PIANO1 = false
- else
- if playPiano1 == "R" then
- nbPiano1 = 1
- else
- term.write(playPiano1.."\n")
- NBPIANO1.setPitch(playPiano1)
- NBPIANO1.triggerNote()
- nbPiano1 = nbPiano1 + 1
- end
- end
- end
- end
- end
- end
- --#2
- if PIANO2 == true then
- playPiano2 = notesPiano2[nbPiano2]
- if TFPiano2Break == true then
- Piano2BreakNB = Piano2BreakNB + 1
- if Piano2BreakNB == Piano2Break then
- TFPiano2Break = false
- Piano2BreakNB = 0
- nbPiano2 = nbPiano2 + 1
- end
- else
- if string.sub(playPiano2, 1, 1) == "#" then
- Piano2Break = tonumber(string.sub(playPiano2, 2))
- TFPiano2Break = true
- else
- if playPiano2 == "/" then
- term.write(playPiano2.."\n")
- nbPiano2 = nbPiano2 + 1
- else
- if playPiano2 == "X" then
- PIANO2 = false
- else
- if playPiano2 == "R" then
- nbPiano2 = 1
- else
- term.write(playPiano2.."\n")
- NBPIANO2.setPitch(playPiano2)
- NBPIANO2.triggerNote()
- nbPiano2 = nbPiano2 + 1
- end
- end
- end
- end
- end
- end
- --#3
- if PIANO3 == true then
- playPiano3 = notesPiano3[nbPiano3]
- if TFPiano3Break == true then
- Piano3BreakNB = Piano3BreakNB + 1
- if Piano3BreakNB == Piano3Break then
- TFPiano3Break = false
- Piano3BreakNB = 0
- nbPiano3 = nbPiano3 + 1
- end
- else
- if string.sub(playPiano3, 1, 1) == "#" then
- Piano3Break = tonumber(string.sub(playPiano3, 2))
- TFPiano3Break = true
- else
- if playPiano3 == "/" then
- term.write(playPiano3.."\n")
- nbPiano3 = nbPiano3 + 1
- else
- if playPiano3 == "X" then
- PIANO3 = false
- else
- if playPiano3 == "R" then
- nbPiano3 = 1
- else
- term.write(playPiano1.."\n")
- NBPIANO3.setPitch(playPiano3)
- NBPIANO3.triggerNote()
- nbPiano3 = nbPiano3 + 1
- end
- end
- end
- end
- end
- end
- --#4
- if PIANO4 == true then
- playPiano4 = notesPiano4[nbPiano4]
- if TFPiano4Break == true then
- Piano4BreakNB = Piano4BreakNB + 1
- if Piano4BreakNB == Piano4Break then
- TFPiano4Break = false
- Piano4BreakNB = 0
- nbPiano4 = nbPiano4 + 1
- end
- else
- if string.sub(playPiano4, 1, 1) == "#" then
- Piano4Break = tonumber(string.sub(playPiano4, 2))
- TFPiano4Break = true
- else
- if playPiano4 == "/" then
- term.write(playPiano4.."\n")
- nbPiano4 = nbPiano4 + 1
- else
- if playPiano4 == "X" then
- PIANO4 = false
- else
- if playPiano4 == "R" then
- nbPiano4 = 1
- else
- term.write(playPiano1.."\n")
- NBPIANO4.setPitch(playPiano4)
- NBPIANO4.triggerNote()
- nbPiano4 = nbPiano4 + 1
- end
- end
- end
- end
- end
- end
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment