Skip to content

A Better way using a couple of Modkeys to load an environment with just those plugins and their masters. #612

@Michael-wigontherun

Description

@Michael-wigontherun

On discord in Dev Forum, "How to construct an environment with only a select few mods enabled and their Masters - Solved" this was discussed.

https://discord.com/channels/759302581448474626/1369726662694142032

This is the way we found to do it

public static void TestTransitiveMasterLocatorToLoadEnviroment()
{

    var locator = new TransitiveMasterLocator(
        new System.IO.Abstractions.FileSystem(),
        new DataDirectoryInjection(@"C:\Steam\steamapps\common\Skyrim Special Edition\Data"),
        new GameReleaseInjection(GameRelease.SkyrimSE));
    ModKey[] NeededPlugins = new ModKey[]
    {
        ModKey.FromFileName("Tem's Houses - Sarethi Farm.esp"),
        ModKey.FromFileName("Lux - Tem's Houses - Sarethi Farm.esp")
    };
    var masters = locator.GetAllMasters(NeededPlugins);
    Console.WriteLine("Masters Found: ");
    foreach (var master in masters)
    {
        Console.WriteLine(master.FileName);
    }

    Console.WriteLine();
    Console.WriteLine();
    HashSet<ModKey> OnlyLoadThese = masters.ToHashSet();
    using var env = GameEnvironment.Typical.Builder<ISkyrimMod, ISkyrimModGetter>(GameRelease.SkyrimSE)
        .TransformLoadOrderListings(x => x.Where(x => OnlyLoadThese.Contains(x.ModKey)))
        .WithTargetDataFolder(@"C:\Steam\steamapps\common\Skyrim Special Edition\Data")
        .Build();
    Console.WriteLine("Plugins Loaded in Environment: ");
    foreach (var plugin in env.LoadOrder.Items)
    {
        Console.WriteLine($"{plugin.ModKey}");
    }
}

Image

But this was a lot of code to accomplish just the basic environment we wanted. Not to mention "TransitiveMasterLocator" was stated to be a primarily back end part of mutagen

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions