Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("buttonAPI")
- m = peripheral.wrap("top")
- m.clear()
- spk = peripheral.wrap("right")
- instlist = {"harp", "bass", "snare", "hat", "basedrum", "flute", "bell", "chime", "guitar", "xylophone", "iron_xylophone", "cow_bell", "didgeridoo", "bit", "banjo", "pling"}
- inst = 1
- function init()
- buttonAPI.label(1,1,instlist[inst])
- for i=0, 23 do
- function funk()
- playKey(i)
- buttonAPI.flash(""..i)
- end
- func=funk
- x=0
- y=0
- if i%2==0 then
- x = 1+i+(i/2)
- y = 2
- else
- x = i+(i/2)
- y = 6
- end
- buttonAPI.setTable(""..i,func,x,x+1,y,y+2)
- end
- buttonAPI.setTable("ins",changeInst,37,39,2,8)
- buttonAPI.screen()
- end
- function changeInst()
- inst=inst+1
- if inst>16 then
- inst = 1
- end
- m.setCursorPos(1,1)
- m.clearLine()
- buttonAPI.label(1,1,instlist[inst])
- buttonAPI.flash("ins")
- end
- function playKey(pitch)
- spk.playNote(instlist[inst],1,pitch)
- end
- function getClick()
- event, side, x,y = os.pullEvent("monitor_touch")
- buttonAPI.checkxy(x,y)
- end
- init()
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement