Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = peripheral.wrap("top")
- volume = 2.0
- songName = "test.lua"
- function playNote(instrument, note)
- s.playNote(instrument, volume, tonumber(note))
- end
- function wait(time)
- time = tonumber(time)*2
- sleep(tonumber(time)*0.05)
- end
- function parse(str)
- if(string.find(str, "delay:")) then
- wait(string.sub(str,7))
- else
- instru_pre = string.match(str, ".*:")
- print(instru_pre)
- instru = string.sub(instru_pre, 1, string.len(instru_pre)-1)
- note_pre = string.match(str, ":.*")
- note = string.sub(note_pre, 2)
- playNote(instru,note)
- end
- end
- function main()
- song = fs.open(songName, "r")
- x = song.readLine()
- while x ~= nil do
- parse(x)
- x = song.readLine()
- end
- end
- main()
Add Comment
Please, Sign In to add comment