string[int] file_to_parse;
string[int] parsed_file;
string[int] item_modifiers_by_item_ID;
string[int] signs = {"Mongoose", "Wallaby", "Vole", "Marmot", "Opossum", "Platypus", "Blender", "Wombat", "Packrat"};
for i from 0 to 8{
for j from 1 to 6{
clear(file_to_parse);
clear(parsed_file);
file_to_parse = file_to_array("TCRS_"+j.to_class().replace_string(" ","_")+"_"+signs[i]+".txt");
for k from 1 to count(file_to_parse){
//lines start with item ID, a tab, item's tcrsname, and another tab.
string[int][int] number_and_name = group_string(file_to_parse[k],"^(\\d+)\t([^\\t]*)\t");
//number_and_name[0][1] is ID
//number_and_name[0][2] is tcrsname.
//convert itemID into item's original name and split into words followed by spaces and stupid boundary characters where appropriate, hopefully.
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]*)");
//make name lowercase;
number_and_name[0][2] = number_and_name[0][2].to_lower_case();
//remove all words found in item name from item's tcrs name
foreach whatever_comes_after_k in words_in_item_name{
number_and_name[0][2] = number_and_name[0][2].replace_string(words_in_item_name[whatever_comes_after_k][1],"");
//replace double spaces with single spaces because somehow that's still a thing despite attempts at caution in line 16.
number_and_name[0][2] = number_and_name[0][2].replace_string(" "," ");
}
//remove trailing and leading whitespace;
number_and_name[0][2] = number_and_name[0][2].group_string("^\\s*(.*)\\s*$")[0][1];
//If you just want the longest list of consecutive items, uncomment the line below.
//if(number_and_name[0][1].to_int() >= 6795 && number_and_name[0][1].to_int() <= 7926){
parsed_file[number_and_name[0][1].to_int()] = number_and_name[0][2];
}
//add 1 to moonsign so that it matches actual sign numbers.
map_to_file(parsed_file, "parsed_tcrs_modifiers_"+j+"_"+(i+1)+".txt");
}
}
print("we did it.");
Comments