Advertisement
MysticT

NBSConverter

Jul 3rd, 2012
1,743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- NBS File Converter
  2. -- by MysticT
  3.  
  4. -- load nbs api
  5. if not nbs then
  6.     os.loadAPI("nbs")
  7.     if not nbs then
  8.         print("Error loading nbs api. Check you installed it correctly.")
  9.         return
  10.     end
  11. end
  12.  
  13. -- Start program
  14.  
  15. -- get arguments
  16. local tArgs = { ... }
  17. if #tArgs ~= 2 then
  18.     print("Usage: nbsconvert <file path> <save path>")
  19.     return
  20. end
  21.  
  22. -- load the song from the nbs file
  23. print("Converting...")
  24. local tSong, err = nbs.load(tArgs[1], true)
  25. if tSong then
  26.     print("File loaded")
  27.     print("Title: ", tSong.name)
  28.     print("Author: ", tSong.author)
  29.     print("Original Author: ", tSong.original_author)
  30.     print("Lenght: ", tSong.lenght)
  31. else
  32.     print("Error: ", err)
  33.     return
  34. end
  35.  
  36. -- save the converted song to a file
  37. local ok, err = nbs.saveSong(tSong, tArgs[2])
  38. if ok then
  39.     print("\nFile saved to", tArgs[2])
  40. else
  41.     print("Error: ", err)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement