Advertisement
yojimbos_law

parsing mafia's tcrs files for modifiers

Jun 24th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. string[int] file_to_parse;
  2. string[int] parsed_file;
  3. string[int] item_modifiers_by_item_ID;
  4. string[int] signs = {"Mongoose", "Wallaby", "Vole", "Marmot", "Opossum", "Platypus", "Blender", "Wombat", "Packrat"};
  5. for i from 0 to 8{
  6. for j from 1 to 6{
  7. clear(file_to_parse);
  8. clear(parsed_file);
  9. file_to_parse = file_to_array("TCRS_"+j.to_class().replace_string(" ","_")+"_"+signs[i]+".txt");
  10. for k from 1 to count(file_to_parse){
  11. //lines start with item ID, a tab, item's tcrsname, and another tab.
  12. string[int][int] number_and_name = group_string(file_to_parse[k],"^(\\d+)\t([^\\t]*)\t");
  13. //number_and_name[0][1] is ID
  14. //number_and_name[0][2] is tcrsname.
  15. //convert itemID into item's original name and split into words followed by spaces and stupid boundary characters where appropriate, hopefully.
  16. string[int][int] words_in_item_name = number_and_name[0][1].to_int().to_item().to_lower_case().group_string("\\b([^\\s]+\\b[^\\w]*)");
  17. //make name lowercase;
  18. number_and_name[0][2] = number_and_name[0][2].to_lower_case();
  19. //remove all words found in item name from item's tcrs name
  20. foreach whatever_comes_after_k in words_in_item_name{
  21. number_and_name[0][2] = number_and_name[0][2].replace_string(words_in_item_name[whatever_comes_after_k][1],"");
  22. //replace double spaces with single spaces because somehow that's still a thing despite attempts at caution in line 16.
  23. number_and_name[0][2] = number_and_name[0][2].replace_string(" "," ");
  24. }
  25. //remove trailing and leading whitespace;
  26. number_and_name[0][2] = number_and_name[0][2].group_string("^\\s*(.*)\\s*$")[0][1];
  27. //If you just want the longest list of consecutive items, uncomment the line below.
  28. //if(number_and_name[0][1].to_int() >= 6795 && number_and_name[0][1].to_int() <= 7926){
  29. parsed_file[number_and_name[0][1].to_int()] = number_and_name[0][2];
  30. }
  31. //add 1 to moonsign so that it matches actual sign numbers.
  32. map_to_file(parsed_file, "parsed_tcrs_modifiers_"+j+"_"+(i+1)+".txt");
  33. }
  34. }
  35. print("we did it.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement