fixed: barotrauma for some reason ignores content packages that only contain lua scripts
This commit is contained in:
@@ -9,6 +9,7 @@ using Barotrauma.Items.Components;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -369,6 +370,29 @@ namespace Barotrauma
|
|||||||
return GameMain.Config.AllEnabledPackages.ToArray();
|
return GameMain.Config.AllEnabledPackages.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<string> GetEnabledPackagesDirectlyFromFile()
|
||||||
|
{
|
||||||
|
List<string> enabledPackages = new List<string>();
|
||||||
|
|
||||||
|
XDocument doc = XMLExtensions.LoadXml("config_player.xml");
|
||||||
|
var contentPackagesElement = doc.Root.Element("contentpackages");
|
||||||
|
|
||||||
|
string coreName = contentPackagesElement.Element("core")?.GetAttributeString("name", "");
|
||||||
|
enabledPackages.Add(coreName);
|
||||||
|
|
||||||
|
XElement regularElement = contentPackagesElement.Element("regular");
|
||||||
|
List<XElement> subElements = regularElement?.Elements()?.ToList();
|
||||||
|
|
||||||
|
foreach (var subElement in subElements)
|
||||||
|
{
|
||||||
|
if (!bool.TryParse(subElement.GetAttributeString("enabled", "false"), out bool enabled) || !enabled) { continue; }
|
||||||
|
|
||||||
|
string name = subElement.GetAttributeString("name", null);
|
||||||
|
enabledPackages.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabledPackages;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ else
|
|||||||
print("LUA LOADER: Only enabled mods will be executed. Lua/MoonsharpSetup.lua")
|
print("LUA LOADER: Only enabled mods will be executed. Lua/MoonsharpSetup.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
local enabledPackages = Game.GetEnabledContentPackages()
|
local enabledPackages = Game.GetEnabledPackagesDirectlyFromFile()
|
||||||
|
|
||||||
local function endsWith(str, suffix)
|
local function endsWith(str, suffix)
|
||||||
return str:sub(-string.len(suffix)) == suffix
|
return str:sub(-string.len(suffix)) == suffix
|
||||||
@@ -34,8 +34,8 @@ local modulePaths = {}
|
|||||||
|
|
||||||
if not runDisabledMods then
|
if not runDisabledMods then
|
||||||
|
|
||||||
for _, package in pairs(enabledPackages) do
|
for _, packageName in pairs(enabledPackages) do
|
||||||
d = package.Name:gsub("\\", "/")
|
d = packageName:gsub("\\", "/")
|
||||||
d = "Mods/" .. d
|
d = "Mods/" .. d
|
||||||
|
|
||||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
||||||
|
|||||||
Reference in New Issue
Block a user