NielsUtrecht

Untitled

Jan 26th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. local songFile = http.get("https://dl.dropbox.com/u/20974501/song.csv")
  2. local note = peripheral.wrap("right")
  3.  
  4. function string:split(delimiter)
  5. local result = { }
  6. local from = 1
  7. local delim_from, delim_to = string.find( self, delimiter, from )
  8. while delim_from do
  9. table.insert( result, string.sub( self, from , delim_from-1 ) )
  10. from = delim_to + 1
  11. delim_from, delim_to = string.find( self, delimiter, from )
  12. end
  13. table.insert( result, string.sub( self, from ) )
  14. return result
  15. end
  16.  
  17. while true do
  18. local line = songFile.readLine()
  19. if line == nil then
  20. break
  21. end
  22.  
  23. local data = string.split(line, ",")
  24.  
  25. local command = data[1]
  26.  
  27. if command == "w" then
  28. print("Sleep ", data[2])
  29. sleep(tonumber(data[2]))
  30. elseif command == "n" then
  31. print("Note ", data[2], data[3])
  32. note.playNote(0,tonumber(data[3]))
  33. else
  34. print("Command: ", command)
  35. end
  36.  
  37. end
  38.  
  39. songFile.close()
Advertisement
Add Comment
Please, Sign In to add comment