Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MonitorSide = "back"
- local side1 = "right" -- the side that has only the 9 noteblocks attached
- local side2 = "front" -- The side that has the remaining 16 noteblocks attached
- local song = {};waittime = 0;recor = false;overlaystat=false
- function drawGUI()
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("PianoSprite"),1,1)
- paintutils.drawImage(paintutils.loadImage("Record") ,2,9)
- term.setCursorPos(8,11)
- write("REC")
- paintutils.drawImage(paintutils.loadImage("Play") ,12,9)
- term.setCursorPos(17,11)
- write("PLAY")
- paintutils.drawImage(paintutils.loadImage("Overlay") ,58,9)
- term.setCursorPos(63,11)
- write("OVERLAY")
- term.restore()
- end
- function play(note)
- --colors = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- --if note <= 8 then redstone.setBundledOutput(side1,colors[note+1]);sleep(0.1);redstone.setBundledOutput(side1,0) end
- --if note >= 9 then redstone.setBundledOutput(side2,colors[note-8]);sleep(0.1);redstone.setBundledOutput(side2,0) end --Avec cable RedPower
- playnote(0,note) --Avec Iron Note Block
- if recor == true then
- table.insert(song,os.clock()-waittime)
- table.insert(song,note)
- waittime = os.clock()
- end
- end
- function playback()
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("Play2") ,12,9)
- term.setCursorPos(17,11)
- write("PLAY")
- for i,v in ipairs(song) do
- if i % 2 == 0 then
- play(v)
- else
- sleep(v-.1)
- end
- end
- sleep(0.5)
- paintutils.drawImage(paintutils.loadImage("Play") ,12,9)
- term.setCursorPos(17,11)
- write("PLAY")
- term.restore()
- end
- function writec(str,x,y)
- term.setCursorPos(x,y)
- write(str)
- end
- drawGUI()
- while true do -- This section tracks where on the screen the player clicks and what to do depending on where it clicks, takes alot of space
- event,side,x,y = os.pullEvent() -- mainly because the notes on the piano arent plain quads so i had to define ech shape
- if event == "monitor_touch" then
- if (x == 3 or x == 4 or x == 5) and y <= 4 then play(0) end -- Note 0/24
- if ((x == 5 or x == 7) and y >= 5 and y <= 7) or (x == 6 and y <= 7) then play(1) end -- Note 1/24
- if (x == 7 or x == 8 or x == 9) and y <= 4 then play(2) end -- Note 2/24
- if ((x == 9 or x == 11) and y >= 5 and y <= 7) or (x == 10 and y <= 7) then play(3) end -- Note 3/24 -- Normal White note
- if (x == 11 or x == 12 or x == 13) and y <= 4 then play(4) end -- Note 4/24 -- Black Note
- if (x == 13 and y >= 5 and y <= 7) or ((x == 14 or x == 15) and y <= 7) then play(5) end -- Note 5/24 -- Backwards L Shape
- if ((x == 17 or x == 18) and y <= 7) or (x == 19 and y >= 5 and y <= 7) then play(6) end -- Note 6/24 -- L Shape
- if (x == 19 or x == 20 or x == 21) and y <= 4 then play(7) end -- Note 7/24
- if ((x == 21 or x == 23) and y >= 5 and y <= 7) or (x == 22 and y <= 7) then play(8) end -- Note 8/24
- if (x == 23 or x == 24 or x == 25) and y <= 4 then play(9) end -- Note 9/24
- if (x == 25 and y >= 5 and y <= 7) or ((x == 26 or x == 27) and y <= 7) then play(10) end -- Note 10/24
- if ((x == 29 or x == 30) and y <= 7) or (x == 31 and y >= 5 and y <= 7) then play(11) end -- Note 11/24
- if (x == 31 or x == 32 or x == 33) and y <= 4 then play(12) end -- Note 12/24
- if ((x == 33 or x == 35) and y >= 5 and y <= 7) or (x == 34 and y <= 7) then play(13) end -- Note 13/24
- if (x == 35 or x == 36 or x == 37) and y <= 4 then play(14) end -- Note 14/24
- if ((x == 37 or x == 39) and y >= 5 and y <= 7) or (x == 38 and y <= 7) then play(15) end -- Note 15/24
- if (x == 39 or x == 40 or x == 41) and y <= 4 then play(16) end -- Note 16/24
- if (x == 41 and y >= 5 and y <= 7) or ((x == 42 or x == 43) and y <= 7) then play(17) end -- Note 17/24
- if ((x == 45 or x == 46) and y <= 7) or (x == 47 and y >= 5 and y <= 7) then play(18) end -- Note 18/24
- if (x == 47 or x == 48 or x == 49) and y <= 4 then play(19) end -- Note 19/24
- if ((x == 49 or x == 51) and y >= 5 and y <= 7) or (x == 50 and y <= 7) then play(20) end -- Note 20/24
- if (x == 51 or x == 52 or x == 53) and y <= 4 then play(21) end -- Note 21/24
- if (x == 53 and y >= 5 and y <= 7) or ((x == 54 or x == 55) and y <= 7) then play(22) end -- Note 22/24
- if ((x == 57 or x == 58) and y <= 7) or (x == 59 and y >= 5 and y <= 7) then play(23) end -- Note 23/24
- if (x == 59 or x == 60 or x == 61) and y <= 4 then play(24) end -- Note 24/24
- if (x <= 11 and x >=3) and (y <=12 and y >= 10) and recor == true then
- recor = false
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("Record") ,2,9)
- term.setCursorPos(8,11)
- write("REC")
- term.restore()
- elseif (x <= 11 and x >=3) and (y <=12 and y >= 10) and recor == false then
- recor = true
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("Record2") ,2,9)
- term.setCursorPos(8,11)
- write("REC")
- term.restore()
- song = {};waittime = os.clock()
- end
- if (x <= 21 and x >=13) and (y <=12 and y >= 10) and song ~= {} and recor == false then playback() end
- if (x >=59 and x <= 70) and (y <=12 and y >= 10) and overlaystat == false then
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("Overlay2") ,58,9)
- term.setCursorPos(63,11)
- term.setTextColor(1)
- write("OVERLAY")
- overlaystat = true
- term.setBackgroundColor(32768)
- writec("F#",4,3);writec("G#",8,3);writec("A#",12,3);writec("C#",20,3);writec("D#",24,3);writec("F#",32,3);writec("G#",36,3);writec("A#",40,3);writec("C#",48,3);writec("D#",52,3);writec("F#",60,3) -- OVERLAY for black keys
- term.setBackgroundColor(1)
- term.setTextColor(32768)
- writec("G",6,6)
- writec("A",10,6)
- writec("B",14,6)
- writec("C",18,6)
- writec("D",22,6)
- writec("E",26,6)
- writec("F",30,6)
- writec("G",34,6)
- writec("A",38,6)
- writec("B",42,6)
- writec("C",46,6)
- writec("D",50,6)
- writec("E",54,6)
- writec("F",58,6)
- term.setTextColor(1)
- term.restore()
- elseif (x >=59 and x <= 70) and (y <=12 and y >= 10) and overlaystat == true then
- drawGUI()
- term.redirect(peripheral.wrap(MonitorSide))
- paintutils.drawImage(paintutils.loadImage("Overlay") ,58,9)
- term.setCursorPos(63,11)
- write("OVERLAY")
- term.restore()
- overlaystat = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement