Advertisement
TheRockettek

Condense

Apr 16th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. tArgs = { ... }
  2. if not tArgs[2] then tArgs[2] = tArgs[1] .. ".song" end
  3. file2 = fs.open(tArgs[2],"a")
  4. lines = io.lines(tArgs[1])
  5. print("Target: " .. tArgs[1])
  6. print("Output: " .. tArgs[2])
  7. print("Working...")
  8. term.setTextColor(colours.orange)
  9. for line in lines do
  10. if line:find("playNote") then
  11. a1,a2 = line:find("(",0,true)
  12. b1,b2 = line:find(",",a2+1,true)
  13. c1,c2 = line:find(")",a2+1,true)
  14. if b1 then
  15. arg1 = line:sub(a2+1,b1-1)
  16. else
  17. arg1 = line:sub(a2+1,c1-1)
  18. end
  19. if b1 then
  20. arg2 = line:sub(b2+1,c1-1)
  21. end
  22. arg2 = arg2:gsub(" ","")
  23. if arg2 then
  24. file2.writeLine("P|" .. arg1 .. "|" .. arg2)
  25. else
  26. file2.writeLine("P|" .. arg1)
  27. end
  28. elseif line:find("sleep") then
  29. local a1,a2 = line:find("(",0,true)
  30. local b1,b2 = line:find(")",0,true)
  31. local arg1 = line:sub(a2+1,b1-1)
  32. file2.writeLine("S|" .. arg1)
  33. end
  34. end
  35. term.setTextColor(colours.white)
  36. print("Done")
  37. file2.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement