diff --git a/BrawlCrate/API/BrawlAPIInternal.cs b/BrawlCrate/API/BrawlAPIInternal.cs index a151a03c8..a8612ca52 100644 --- a/BrawlCrate/API/BrawlAPIInternal.cs +++ b/BrawlCrate/API/BrawlAPIInternal.cs @@ -54,12 +54,7 @@ static BrawlAPIInternal() Directory.Delete($"{Application.StartupPath}\\BrawlAPI\\Python", true); } // Setup IronPython engine - Engine.SetSearchPaths(new[] - { - $"{Application.StartupPath}\\BrawlAPI\\Lib\\Python", - $"{Application.StartupPath}\\BrawlAPI\\Lib" - }); - + UpdateSearchPaths(); fsi_path = Properties.Settings.Default.FSharpInstallationPath; //Import BrawlCrate and Brawllib @@ -76,6 +71,15 @@ static BrawlAPIInternal() MainForm.Instance.resourceTree.SelectionChanged += ResourceTree_SelectionChanged; } + internal static void UpdateSearchPaths() + { + string libPath = Path.GetFullPath($"{Application.StartupPath}\\BrawlAPI\\Lib"); + if (!string.IsNullOrEmpty(libPath)) + { + Engine.SetSearchPaths(Directory.GetDirectories(libPath).Append(libPath).ToArray()); + } + } + internal static ScriptEngine Engine { get; set; } internal static ScriptRuntime Runtime { get; set; } diff --git a/BrawlCrate/UI/MainForm.cs b/BrawlCrate/UI/MainForm.cs index 8014719e5..9d52e6a88 100644 --- a/BrawlCrate/UI/MainForm.cs +++ b/BrawlCrate/UI/MainForm.cs @@ -1458,6 +1458,7 @@ public void reloadPluginsToolStripMenuItem_Click(object sender, EventArgs e) pluginToolStripMenuItem.DropDown.Items.Clear(); AddPlugins(pluginToolStripMenuItem, Program.ApiPluginPath); pluginToolStripMenuItem.Enabled = pluginToolStripMenuItem.HasDropDownItems; + BrawlAPIInternal.UpdateSearchPaths(); } public static List GetScripts(string path)