Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Just put this code somewhere else, call "cod()" and it's all automatically parsed.
- // INPUT: Convert the .crs into .txt and overwrite the code.
- // OUTPUT: output_mods.xml
- public static void cod()
- {
- File.WriteAllText(@"output_mods.xml",string.Empty);
- List<string> itgmods = new List<string>() {"<ActorFrame><children>","<Layer","Type=\"Quad\"","InitCommand=\"hidden,1\"","OnCommand=\"%function(self)","mods={"};
- List<string> xmlmods = new List<string>();
- // Insert file name here. v
- using(StreamReader sr = new StreamReader(@"INSERTNAME.txt")) {
- string line;
- while ((line=sr.ReadLine()) != null) {
- string s = "", e = "", eol = "";
- string[] m = {};
- if (line.Length >= 6 && line.Substring(0,6) == "#MODS:") {
- line = line.Remove(0,6);
- if (line.Substring(0,5) == "TIME=") {
- string fuck = "";
- string ery = line.Substring(5);
- List<string> shit = new List<string>() {"1","2","3","4","5","6","7","8","9","0","."};
- bool isnum = true;
- int curr = 0;
- while(isnum) {
- if(shit.Any(x => x == ery[curr].ToString())) {
- fuck = fuck + ery[curr];
- curr = curr + 1;
- } else {
- s = fuck;
- break;
- }
- }
- }
- line = line.Remove(0,6+s.Length);
- if (line.Substring(0,4) == "END=") {
- eol = "end";
- string fuck = "";
- string ery = line.Substring(4);
- List<string> shit = new List<string>() {"1","2","3","4","5","6","7","8","9","0","."};
- bool isnum = true;
- int curr = 0;
- while(isnum) {
- if(shit.Any(x => x == ery[curr].ToString())) {
- fuck = fuck + ery[curr];
- curr = curr + 1;
- } else {
- e = fuck;
- break;
- }
- }
- } else if (line.Substring(0,4) == "LEN=") {;
- eol = "len";
- string fuck = "";
- string ery = line.Substring(5);
- List<string> shit = new List<string>() {"1","2","3","4","5","6","7","8","9","0","."};
- bool isnum = true;
- int curr = 0;
- // Using the same shit as the TIME
- while(isnum) {
- // If letter is num
- if(shit.Any(x => x == ery[curr].ToString())) {
- fuck = fuck + ery[curr];
- curr = curr + 1;
- } else {
- e = fuck;
- break;
- }
- }
- }
- line = line.Remove(0,4+e.Length);
- if (e.Substring(0,1) == ".") {
- line = line.Remove(0,7);
- } else {
- line = line.Remove(0,6);
- }
- line = line.Substring(0,line.Length-1);
- m = line.Split(',');
- if (s+e+eol != "") {
- parseMods(s,e,m,eol,xmlmods);
- }
- }
- }
- }
- foreach(string s in xmlmods) {
- itgmods.Add(s);
- }
- itgmods.Add("}");
- itgmods.Add("end\"");
- itgmods.Add("/>");
- itgmods.Add("</children></ActorFrame>");
- foreach(string s in itgmods) {
- using(StreamWriter sw = new StreamWriter(@"output_mods.xml",true)) {
- sw.WriteLine(s);
- }
- }
- }
- public static void parseMods(string Start, string End, string[] Mods, string EndType,List<string> output) {
- string mod = "{";
- mod = mod + Start + ",";
- mod = mod + End + ",";
- if(Mods.Count() == 1) {
- mod = mod + "\'" + Mods[0] + "\',";
- } else {
- string tempmod = "";
- tempmod = tempmod + "\'";
- foreach(string s in Mods) {
- tempmod = tempmod + s + ",";
- }
- tempmod = tempmod.Substring(0,tempmod.Length-1);
- tempmod = tempmod + "\',";
- mod = mod + tempmod;
- }
- mod = mod + "\'" + EndType + "\'";
- mod = mod + "},";
- output.Add(mod);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement