Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local songFile = http.get("https://dl.dropbox.com/u/20974501/song.csv")
- local note = peripheral.wrap("right")
- function string:split(delimiter)
- local result = { }
- local from = 1
- local delim_from, delim_to = string.find( self, delimiter, from )
- while delim_from do
- table.insert( result, string.sub( self, from , delim_from-1 ) )
- from = delim_to + 1
- delim_from, delim_to = string.find( self, delimiter, from )
- end
- table.insert( result, string.sub( self, from ) )
- return result
- end
- while true do
- local line = songFile.readLine()
- if line == nil then
- break
- end
- local data = string.split(line, ",")
- local command = data[1]
- if command == "w" then
- print("Sleep ", data[2])
- sleep(tonumber(data[2]))
- elseif command == "n" then
- print("Note ", data[2], data[3])
- note.playNote(0,tonumber(data[3]))
- else
- print("Command: ", command)
- end
- end
- songFile.close()
Advertisement
Add Comment
Please, Sign In to add comment