Advertisement
Jousway

sm8keyto5key.lua

Sep 25th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. function iswindows()
  2.     osver = io.popen("ver"):read("*a");
  3.     if string.match(osver, 'Windows') ~= nil then
  4.         return true;
  5.     else
  6.         os.execute("clear");
  7.     end;
  8. end;
  9.  
  10. function clear()
  11.     if iswindows() then
  12.         os.execute("cls");
  13.     else
  14.         os.execute("clear");
  15.     end;
  16. end;
  17.  
  18. repeat
  19.     clear();
  20.     io.write("do you want to convert: "..string.match(arg[1], ".+\\(.-%.sm)").." y/n: ");
  21.     selection = io.read();
  22. until selection == "y" or selection == "n";
  23.  
  24. newline = "";
  25. newinfo = "";
  26.  
  27. if selection == "y" then
  28.     f = io.open(arg[1], "r");
  29.     oldfile = f:read("*all");
  30.     for str in string.gmatch(oldfile, "(#NOTES:.-;)") do
  31.         if string.find(str, "dance%-double") then
  32.             newline = newline.."\n//---------------pump-single - ----------------\n";
  33.             for info in string.gmatch(str, "(#NOTES:.+:)") do
  34.                 newinfo = newinfo.."\n\n//---------------pump-single - ----------------\n"
  35.                 for infoline in string.gmatch(info, "(.-:)") do
  36.                     if string.find(infoline, "double") then
  37.                         infoline = "\n     pump-single:"
  38.                     end;
  39.                     newline = newline..infoline;
  40.                     newinfo = newinfo..infoline
  41.                 end
  42.             end
  43.             newline = newline.."\n";
  44.             for setend in string.gmatch(str, "(.+);") do
  45.                     str = setend..",";
  46.             end;
  47.             for line in string.gmatch(str, "(.-)%,") do
  48.                 for Left1, Down1, Up1, Right1, Left2, Down2, Up2, Right2 in string.gmatch(line, "(%d)(%d)(%d)(%d)(%d)(%d)(%d)(%d)") do
  49.                     Center = Left1;
  50.                     DownLeft = Left2;
  51.                     if tonumber(Down1) > 0 or tonumber(Down2) > 0 then
  52.                         UpLeft = 1;
  53.                     else
  54.                         UpLeft = 0;
  55.                     end;
  56.                     if tonumber(Up1) > 0 or tonumber(Up2) > 0 then
  57.                         UpRight = 1;
  58.                     else
  59.                         UpRight = 0;
  60.                     end;
  61.                     if tonumber(Right1) > 0 or tonumber(Right2) > 0 then
  62.                         DownRight = 1;
  63.                     else
  64.                         DownRight = 0;
  65.                     end;       
  66.                     setline = DownLeft..UpLeft..Center..UpRight..DownRight;
  67.                     newline = newline..setline.."\n";
  68.                     showdot = true
  69.                 end;
  70.                 if showdot then
  71.                     newline = newline..",\n";
  72.                     showdot = false
  73.                 end;
  74.             end;
  75.             for fixend in string.gmatch(newline, "(.+)%,") do
  76.                 newline = fixend..";\n";
  77.             end;
  78.         end;
  79.     end;
  80.     print(newinfo);
  81.     io.close(f)
  82.     f = io.open(string.match(arg[1], ".+\\(.-%.sm)").."new", "w")
  83.     f:write(oldfile..newline)
  84.     io.close(f)
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement