FIXED ALCOHOLhttp://dffd.bay12games.com/file.php?id=12612Standardizes: wood, alcohol, meat, flour, leather, wool, silk, plant fiber, tallow, oil, and soap.
Here is the code below. You can use it if you want, but please at least credit me.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Standardized_Material_Mod
{
class Program
{
static void Main()
{
List<string> lines = new List<string>();
string concatenate = "";
string destination;
string[] plant = Directory.GetFiles(@".\\raw\\objects\", "plant*");
string[] tissue = Directory.GetFiles(@".\\raw\\objects\", "tissue*");
string[] creature = Directory.GetFiles(@".\\raw\\objects\", "creature*");
// Standardize Plant Products
for (int i = 0; i < plant.Length; i++)
{
destination = plant[i];
using (StreamReader file = new StreamReader(destination))
{
string line;
while ((line = file.ReadLine()) != null)
{
concatenate = concatenate + line;
}
}
lines.Add(concatenate.Substring(0, concatenate.IndexOf("[")));
while (concatenate.Contains("]"))
{
if (1 + concatenate.IndexOf("]") - concatenate.IndexOf("[") > 0)
{
lines.Add(concatenate.Substring(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("[")));
concatenate = concatenate.Remove(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("["));
}
else
{
concatenate = concatenate.Remove(0, 1 + concatenate.IndexOf("]"));
}
}
using (StreamWriter file = new StreamWriter(destination))
{
int j = 0;
while (j < lines.Count)
{
if (lines[j].Contains("PLANT:"))
{
// Standardize Wood, Drink, Thread, Oil, Soap, and Flour
int k = 1;
bool dye = false;
bool tree = false;
bool leaves = false;
while (j + k < lines.Count && !lines[j + k].Contains("PLANT:"))
{
if (lines[j + k].Contains("POWDER_DYE:"))
{
dye = true;
}
if (lines[j + k].Contains("TREE:"))
{
tree = true;
}
if (lines[j + k].Contains("ITEM_REACTION_PRODUCT:BAG_ITEM:PLANT_GROWTH:LEAVES:LOCAL_PLANT_MAT:LEAF"))
{
leaves = true;
}
k++;
}
k = 1;
while (j + k < lines.Count && !lines[j + k].Contains("PLANT:"))
{
if (lines[j + k].Contains("TREE:LOCAL_PLANT_MAT:WOOD") ||
lines[j + k].Contains("DRINK:LOCAL_PLANT_MAT:DRINK") ||
lines[j + k].Contains("THREAD:LOCAL_PLANT_MAT:THREAD") ||
lines[j + k].Contains("MATERIAL_REACTION_PRODUCT:DRINK_MAT:LOCAL_PLANT_MAT:DRINK") ||
lines[j + k].Contains("MATERIAL_REACTION_PRODUCT:PRESS_LIQUID_MAT:LOCAL_PLANT_MAT:OIL") ||
lines[j + k].Contains("MATERIAL_REACTION_PRODUCT:PRESS_PAPER_MAT:LOCAL_PLANT_MAT:THREAD") ||
(lines[j + k].Contains("MILL:LOCAL_PLANT_MAT:MILL") && !dye))
{
lines[j + k] = lines[j + k].Replace("LOCAL_PLANT_MAT", "PLANT_MAT:PLANT_PRODUCT");
}
if (lines[j + k].Contains("STATE_NAME_ADJ:ALL_SOLID:dimple dye"))
{
lines[j + k] = lines[j + k].Replace("dimple", "blue");
}
if (lines[j + k].Contains("STATE_NAME_ADJ:ALL_SOLID:emerald dye"))
{
lines[j + k] = lines[j + k].Replace("emerald", "green");
}
if (lines[j + k].Contains("STATE_NAME_ADJ:ALL_SOLID:redroot dye"))
{
lines[j + k] = lines[j + k].Replace("redroot", "red");
}
if (lines[j + k].Contains("STATE_NAME_ADJ:ALL_SOLID:sliver dye"))
{
lines[j + k] = lines[j + k].Replace("sliver", "black");
}
// Remove Tree Seeds
if (tree && (
lines[j + k].Contains("MATERIAL_REACTION_PRODUCT:SEED_MAT:LOCAL_PLANT_MAT:SEED") ||
lines[j + k].Contains("GROWTH_HAS_SEED") ||
lines[j + k].Contains("SEED:")))
{
lines.RemoveAt(j + k);
k--;
}
// Remove Growths
if (lines[j + k].Contains("GROWTH:FLOWERS") ||
lines[j + k].Contains("GROWTH:POD") ||
lines[j + k].Contains("GROWTH:NUT") ||
lines[j + k].Contains("GROWTH:SPATHES") ||
lines[j + k].Contains("GROWTH:SEED") ||
lines[j + k].Contains("GROWTH:CONE") ||
lines[j + k].Contains("GROWTH:SEED_CONE") ||
lines[j + k].Contains("GROWTH:SEED_CATKINS") ||
lines[j + k].Contains("GROWTH:POLLEN_CONE") ||
lines[j + k].Contains("GROWTH:POLLEN_CATKINS"))
{
lines.RemoveAt(j + k);
while (j + k < lines.Count && lines[j + k].Contains("GROWTH_"))
{
lines.RemoveAt(j + k);
}
k--;
}
if (!tree && !leaves && lines[j + k].Contains("GROWTH:LEAVES"))
{
lines.RemoveAt(j + k);
while (j + k < lines.Count && lines[j + k].Contains("GROWTH_"))
{
lines.RemoveAt(j + k);
}
k--;
}
// Remove Materials
if (lines[j + k].Contains("USE_MATERIAL_TEMPLATE:WOOD:") ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:DRINK:") ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:THREAD:") ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:OIL:") ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:SOAP:") ||
(lines[j + k].Contains("USE_MATERIAL_TEMPLATE:MILL:") && !dye) ||
(lines[j + k].Contains("USE_MATERIAL_TEMPLATE:SEED:") && tree) ||
(lines[j + k].Contains("USE_MATERIAL_TEMPLATE:LEAF:") && !tree && !leaves) ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:FLOWER:"))
{
lines.RemoveAt(j + k);
while (j + k < lines.Count && (
lines[j + k].Contains("STATE_NAME:") ||
lines[j + k].Contains("STATE_NAME_ADJ:") ||
lines[j + k].Contains("STATE_ADJ:") ||
lines[j + k].Contains("STATE_COLOR:") ||
lines[j + k].Contains("DISPLAY_COLOR:") ||
lines[j + k].Contains("PREFIX:") ||
lines[j + k].Contains("SOLID_DENSITY:") ||
lines[j + k].Contains("MAT_FIXED_TEMP:") ||
lines[j + k].Contains("MATERIAL_VALUE:") ||
lines[j + k].Contains("EDIBLE_RAW") ||
lines[j + k].Contains("EDIBLE_COOKED") ||
lines[j + k].Contains("EDIBLE_VERMIN") ||
lines[j + k].Contains("REACTION_CLASS:") ||
lines[j + k].Contains("STOCKPILE_GLOB_PASTE") ||
lines[j + k].Contains("STOCKPILE_PLANT_GROWTH")))
{
lines.RemoveAt(j + k);
}
k--;
}
// Make Seeds Inedible
if (lines[j + k].Contains("USE_MATERIAL_TEMPLATE:SEED:"))
{
int l = 1;
while (j + k + l < lines.Count && !lines[j + k + l].Contains("SEED:"))
{
if (lines[j + k + l].Contains("MATERIAL_VALUE:") ||
lines[j + k + l].Contains("EDIBLE_VERMIN") ||
lines[j + k + l].Contains("EDIBLE_RAW") ||
lines[j + k + l].Contains("EDIBLE_COOKED") ||
lines[j + k + l].Contains("STATE_COLOR:") ||
lines[j + k + l].Contains("DISPLAY_COLOR:"))
{
lines.RemoveAt(j + k + l);
l--;
}
l++;
}
}
k++;
}
}
j++;
}
j = 0;
while (j < lines.Count)
{
if (lines[j].Contains("PLANT:"))
{
// Remove Plants Without A Useable Product
int k = 1;
bool useless = true;
while (j + k < lines.Count && !lines[j + k].Contains("PLANT:"))
{
if (lines[j + k].Contains("TREE:") ||
lines[j + k].Contains("DRINK:") ||
lines[j + k].Contains("THREAD:") ||
lines[j + k].Contains("MILL:") ||
lines[j + k].Contains("EDIBLE_RAW") ||
lines[j + k].Contains("EDIBLE_COOKED") ||
lines[j + k].Contains("GROWTH:LEAVES") ||
lines[j + k].Contains("GROWTH:FRUIT:") ||
lines[j + k].Contains("GROWTH:BUDS:") ||
lines[j + k].Contains("GROWTH:BULB:") ||
lines[j + k].Contains("GROWTH:HEART:") ||
lines[j + k].Contains("USE_MATERIAL_TEMPLATE:EXTRACT:") ||
lines[j + k].Contains("REACTION_CLASS:PAPER_PLANT:") ||
lines[j + k].Contains("[GRASS]"))
{
useless = false;
}
k++;
}
if (useless)
{
lines.RemoveAt(j);
while (j < lines.Count && !lines[j].Contains("PLANT:"))
{
lines.RemoveAt(j);
}
j--;
}
}
j++;
}
for (j = 0; j < lines.Count; j++)
{
file.WriteLine(lines[j]);
}
concatenate = "";
lines.Clear();
}
}
// Standardize Tissue
for (int i = 0; i < tissue.Length; i++)
{
destination = tissue[i];
using (StreamReader file = new StreamReader(destination))
{
string line;
while ((line = file.ReadLine()) != null)
{
concatenate = concatenate + line;
}
}
lines.Add(concatenate.Substring(0, concatenate.IndexOf("[")));
while (concatenate.Contains("]"))
{
if (1 + concatenate.IndexOf("]") - concatenate.IndexOf("[") > 0)
{
lines.Add(concatenate.Substring(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("[")));
concatenate = concatenate.Remove(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("["));
}
else
{
concatenate = concatenate.Remove(0, 1 + concatenate.IndexOf("]"));
}
}
using (StreamWriter file = new StreamWriter(destination))
{
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("TISSUE_MATERIAL:LOCAL_CREATURE_MAT"))
{
lines[j] = lines[j].Replace("TISSUE_MATERIAL:LOCAL_CREATURE_MAT", "TISSUE_MATERIAL:CREATURE_MAT:CREATURE_PRODUCT");
}
}
for (int j = 0; j < lines.Count; j++)
{
file.WriteLine(lines[j]);
}
concatenate = "";
lines.Clear();
}
}
// Standardize Animal Products
for (int i = 0; i < creature.Length; i++)
{
destination = creature[i];
using (StreamReader file = new StreamReader(destination))
{
string line;
while ((line = file.ReadLine()) != null)
{
concatenate = concatenate + line;
}
}
lines.Add(concatenate.Substring(0, concatenate.IndexOf("[")));
while (concatenate.Contains("]"))
{
if (1 + concatenate.IndexOf("]") - concatenate.IndexOf("[") > 0)
{
lines.Add(concatenate.Substring(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("[")));
concatenate = concatenate.Remove(concatenate.IndexOf("["), 1 + concatenate.IndexOf("]") - concatenate.IndexOf("["));
}
else
{
concatenate = concatenate.Remove(0, 1 + concatenate.IndexOf("]"));
}
}
using (StreamWriter file = new StreamWriter(destination))
{
// Standardize Tendons, Legaments, Blood, Ichor, Pus, Milk, and Silk
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("TENDONS:LOCAL_CREATURE_MAT:SINEW") ||
lines[j].Contains("LIGAMENTS:LOCAL_CREATURE_MAT:SINEW") ||
lines[j].Contains("BLOOD:LOCAL_CREATURE_MAT:BLOOD") ||
lines[j].Contains("BLOOD:LOCAL_CREATURE_MAT:ICHOR") ||
lines[j].Contains("PUS:LOCAL_CREATURE_MAT:PUS") ||
lines[j].Contains("MILKABLE:LOCAL_CREATURE_MAT:MILK") ||
lines[j].Contains("WEBBER:LOCAL_CREATURE_MAT:SILK"))
{
lines[j] = lines[j].Replace("LOCAL_CREATURE_MAT", "CREATURE_MAT:CREATURE_PRODUCT");
}
}
// Standardize Wools
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("[TISSUE_NAME:wool:NP]"))
{
lines.Insert(j + 1, "[TISSUE_MATERIAL:CREATURE_MAT:CREATURE_PRODUCT:WOOL]");
}
}
// Fix Troll Fur
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("CREATURE:TROLL"))
{
int k = 1;
while (j + k < lines.Count && !lines[j + k].Contains("CREATURE:"))
{
if (lines[j + k].Contains("USE_TISSUE_TEMPLATE:IVORY:IVORY_TEMPLATE"))
{
lines.Insert(j + k + 1, "[SELECT_TISSUE:HAIR]");
lines.Insert(j + k + 2, "[TISSUE_NAME:fur:NP]");
lines.Insert(j + k + 3, "[TISSUE_MATERIAL:CREATURE_MAT:CREATURE_PRODUCT:FUR]");
}
k++;
}
}
}
// Fix Wagon Wood
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("TISSUE_MATERIAL:LOCAL_CREATURE_MAT:WOOD"))
{
lines[j] = lines[j].Replace("LOCAL_CREATURE_MAT", "PLANT_MAT:PLANT_PRODUCT");
}
if (lines[j].Contains("ITEMCORPSE:WOOD:NO_SUBTYPE:LOCAL_CREATURE_MAT:WOOD"))
{
lines[j] = lines[j].Replace("LOCAL_CREATURE_MAT", "PLANT_MAT:PLANT_PRODUCT");
}
}
// Remove Materials
for (int j = 0; j < lines.Count; j++)
{
if (lines[j].Contains("BODY_DETAIL_PLAN:STANDARD_MATERIALS") ||
lines[j].Contains("BODY_DETAIL_PLAN:CHITIN_MATERIALS"))
{
lines.RemoveAt(j);
j--;
}
if (lines[j].Contains("USE_MATERIAL_TEMPLATE:SKIN:SKIN_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:FAT:FAT_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:MUSCLE:MUSCLE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:BONE:BONE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SHELL:SHELL_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:HORN:HORN_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:HOOF:HOOF_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:CARTILAGE:CARTILAGE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:HAIR:HAIR_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:FEATHER:FEATHER_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SCALE:SCALE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:NAIL:NAIL_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:CLAW:NAIL_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:TALON:NAIL_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:TOOTH:TOOTH_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:IVORY:TOOTH_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:EYE:EYE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:NERVE:NERVE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:BRAIN:BRAIN_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:LUNG:LUNG_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:HEART:HEART_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:LIVER:LIVER_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:GUT:GUT_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:STOMACH:STOMACH_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:GIZZARD:GIZZARD_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:PANCREAS:PANCREAS_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SPLEEN:SPLEEN_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:KIDNEY:KIDNEY_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:FLAME:FLAME_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:CHITIN:CHITIN_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SPINE:NAIL_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SPONGE:SPONGE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SINEW:SINEW_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:BLOOD:BLOOD_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:ICHOR:ICHOR_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:PUS:PUS_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:LEATHER:LEATHER_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:PARCHMENT:PARCHMENT_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:TALLOW:TALLOW_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SOAP:SOAP_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:MILK:MILK_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:CHEESE:CREATURE_CHEESE_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:SILK:SILK_TEMPLATE") ||
lines[j].Contains("USE_MATERIAL_TEMPLATE:WOOD:WOOD_TEMPLATE") ||
lines[j].Contains("SELECT_MATERIAL:") ||
lines[j].Contains("REMOVE_MATERIAL:"))
{
lines.RemoveAt(j);
while (j < lines.Count && (
lines[j].Contains("STATE_NAME:") ||
lines[j].Contains("STATE_ADJ:") ||
lines[j].Contains("STATE_COLOR:") ||
lines[j].Contains("PREFIX:") ||
lines[j].Contains("YARN")))
{
lines.RemoveAt(j);
}
j--;
}
}
for (int j = 0; j < lines.Count; j++)
{
file.WriteLine(lines[j]);
}
concatenate = "";
lines.Clear();
}
}