Jump to content

Is there a way to use TES5Edit to export data to text file?


nexodexo

Recommended Posts

I am using Apothecary for LE here:

 

https://www.nexusmods.com/skyrim/mods/109298

 

It overhauls alchemy ingredients, so almost all of them have brand new effects. This renders my current potion/ingredient list unusable, so I want to make a new one since I can't find an existing list.

 

I opened the mod in TES5Edit and I can see all the ingredients and their effects as shown below. If I could export all of this into some format, I could parse it with c# and build my own list. Would be useful for other mods that overhaul alchemy or anything else. Anyone know if this can be done using TES5Edit or any other tool?

 

See attachment for screenshot of TES5Edit screen.

 

 

 

Link to comment
Share on other sites

Never mind. I figured out how to do it. I got the Bethesda Toolkit utility here:

 

https://www.nexusmods.com/skyrim/mods/101736?tab=description

 

I used that to export the .esp to XML. I then wrote some quick and dirty c# to parse it out into a flat file which I prettied up in LibreOffice for printing out. I may as well share the code, though it's nothing special.

    public static void IngredientExport()
    {
        var doc = new XmlDocument();

        doc.Load(@"c:\path\to\modxml.esx");

        //get all the ingredients and their effect ids
        var ingredients = doc
            .SelectNodes("plugin/GRUP[@label=\"INGR\"]/INGR")
            .OfType<XmlElement>()
            .Select(x => new
            {
                id = x.GetAttribute("id"),
                name = x.SelectSingleNode("FULL").InnerText,
                effectIds = x.SelectNodes("EFID").OfType<XmlElement>().Select(efid => efid.InnerText).ToArray()
            })
            .ToArray();

        //get all effects and map them to the above ingredients
        var effects = doc
            .SelectNodes("plugin/GRUP[@label=\"MGEF\"]/MGEF")
            .OfType<XmlElement>()
            .Select(x =>
            {
                var id = x.GetAttribute("id");
                var effect = new
                {
                    id,
                    name = x.SelectSingleNode("FULL").InnerText,
                    ingredients = ingredients.Where(ing => ing.effectIds.Contains(id)).OrderBy(x => x.name).ToArray()
                };
                return effect;
            })
            .Where(x => x.ingredients.Length > 0)
            .OrderBy(x => x.name)
            .ToList();

        //build the flat file
        var flat = effects
            .Select(e => $"{e.name}\r\n{e.ingredients.Select(i => i.name).ToNewLineDelimitedString()}")
            .ToDelimitedString("\r\n\r\n");
    }
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...