SHOW:
|
|
- or go back to the newest paste.
| 1 | local speaker = peripheral.find('speaker')
| |
| 2 | if not speaker then | |
| 3 | error('No speaker found!')
| |
| 4 | end | |
| 5 | ||
| 6 | local list = {
| |
| 7 | {'Blocks','music_disc.blocks'},
| |
| 8 | {'Cat','music_disc.cat'},
| |
| 9 | {'Chirp','music_disc.chirp'},
| |
| 10 | {'Far','music_disc.far'},
| |
| 11 | {'Mall','music_disc.mall'},
| |
| 12 | {'Mellohi','music_disc.mellohi'},
| |
| 13 | {'Stal','music_disc.stal'},
| |
| 14 | {'Strad','music_disc.strad'},
| |
| 15 | {'Wait','music_disc.wait'},
| |
| 16 | {'Ward','music_disc.ward'},
| |
| 17 | } | |
| 18 | ||
| 19 | term.clear() | |
| 20 | term.setCursorPos(1,1) | |
| 21 | print('Please input the track to play')
| |
| 22 | term.setCursorPos(1,5) | |
| 23 | for i,v in pairs(list) do | |
| 24 | print(' -'..v[1])
| |
| 25 | end | |
| 26 | while true do | |
| 27 | term.setCursorPos(1,3) | |
| 28 | term.clearLine() | |
| 29 | term.setCursorPos(1,3) | |
| 30 | local input = read() | |
| 31 | for i,v in pairs(list) do | |
| 32 | if string.lower(v[1]) == string.lower(input) then | |
| 33 | speaker.playSound(v[2],2) | |
| 34 | end | |
| 35 | end | |
| 36 | end |