SHOW:
|
|
- or go back to the newest paste.
| 1 | - | print("ari's piano - use qwerty to play (:")
|
| 1 | + | volume = 3.0 |
| 2 | speaker = peripheral.find("speaker")
| |
| 3 | instrument = "pling" | |
| 4 | - | local event, key, isHeld = os.pullEvent("key")
|
| 4 | + | keyInstruments = {
|
| 5 | - | |
| 5 | + | [keys.h]="harp", |
| 6 | - | if key == keys.q then |
| 6 | + | [keys.j]="pling", |
| 7 | - | print ("G")
|
| 7 | + | [keys.k]="chime", |
| 8 | - | speaker.playSound("minecraft:block.note_block.harp",2,.53)
|
| 8 | + | [keys.l]="iron_xylophone", |
| 9 | - | elseif key == keys.two then |
| 9 | + | [keys.b]="bass", |
| 10 | - | print ("G#")
|
| 10 | + | [keys.n]="guitar", |
| 11 | - | speaker.playSound("minecraft:block.note_block.harp",2,.572)
|
| 11 | + | [keys.m]="banjo", |
| 12 | - | elseif key == keys.w then |
| 12 | + | [keys.comma]="didgeridoo", |
| 13 | - | print ("A")
|
| 13 | + | [keys.period]="bit" |
| 14 | - | speaker.playSound("minecraft:block.note_block.harp",2,.595)
|
| 14 | + | } |
| 15 | - | elseif key == keys.three then |
| 15 | + | |
| 16 | - | print ("A#")
|
| 16 | + | keyNotes = {[keys.one]=0, [keys.q]=1, [keys.two]=2, [keys.w]=3, [keys.three]=4, [keys.e]=5, [keys.r]=6, [keys.five]=7, [keys.t]=8, [keys.six]=9, [keys.y]=10, [keys.u]=11, [keys.eight]=12, [keys.i]=13, [keys.nine]=14, [keys.o]=15, [keys.zero]=16, [keys.p]=17, [keys.z]=18, [keys.s]=19, [keys.x]=20, [keys.d]=21, [keys.c]=22, [keys.v]=23, [keys.g]=24}
|
| 17 | - | speaker.playSound("minecraft:block.note_block.harp",2,.63)
|
| 17 | + | |
| 18 | - | elseif key == keys.e then |
| 18 | + | noteNames = {[0]="F#3", "G3", "G#3", "A3", "A#3", "B3", "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4", "C5", "C#5", "D5", "D#5", "E5", "F5", "F#5"}
|
| 19 | - | print ("B")
|
| 19 | + | |
| 20 | - | speaker.playSound("minecraft:block.note_block.harp",2,.67)
|
| 20 | + | shell.run("clear")
|
| 21 | - | elseif key == keys.r then |
| 21 | + | print("Switch instrument with \"HJKLBNM,.\"")
|
| 22 | - | print ("C")
|
| 22 | + | |
| 23 | - | speaker.playSound("minecraft:block.note_block.harp",2,.71)
|
| 23 | + | |
| 24 | - | elseif key == keys.five then |
| 24 | + | local event, key, isHeld = os.pullEvent("key")
|
| 25 | - | print ("C#")
|
| 25 | + | if keyNotes[key] ~= nil then |
| 26 | - | speaker.playSound("minecraft:block.note_block.harp",2,.75)
|
| 26 | + | speaker.playNote(instrument, volume, keyNotes[key]) |
| 27 | - | elseif key == keys.t then |
| 27 | + | print(noteNames[keyNotes[key]]) |
| 28 | - | print ("D")
|
| 28 | + | elseif keyInstruments[key] ~= nil then |
| 29 | - | speaker.playSound("minecraft:block.note_block.harp",2,.795)
|
| 29 | + | instrument = keyInstruments[key] |
| 30 | - | elseif key == keys.six then |
| 30 | + | print("Instrument: "..instrument)
|
| 31 | - | print ("D#")
|
| 31 | + | print("HJKLBNM,.")
|
| 32 | - | speaker.playSound("minecraft:block.note_block.harp",2,.84)
|
| 32 | + | end |
| 33 | - | elseif key == keys.y then |
| 33 | + |