diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs index 6cffc4c8a..3b50088c3 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs @@ -9,13 +9,13 @@ namespace Barotrauma { if (!File.Exists(LuaCsSetup.VERSION_FILE)) { return; } - ContentPackage luaCsPackage = LuaCsSetup.GetPackage(); - string luaCsPath = Path.GetDirectoryName(luaCsPackage.Path); + ContentPackage luaPackage = LuaCsSetup.GetPackage("LuaForBarotraumaUnstable"); + string luaCsPath = Path.GetDirectoryName(luaPackage.Path); - if (luaCsPackage == null) { return; } + if (luaPackage == null) { return; } string clientVersion = File.ReadAllText(LuaCsSetup.VERSION_FILE); - string workshopVersion = luaCsPackage.ModVersion; + string workshopVersion = luaPackage.ModVersion; if (clientVersion == workshopVersion) { return; } diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index a15fb8934..9c66b7c26 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1255,11 +1255,11 @@ namespace Barotrauma GameMain.LuaCs.Initialize(); })); - commands.Add(new Command("install_cl_lua", "Installs client-Side Lua into your client.", (string[] args) => + commands.Add(new Command("install_cl_lua", "Installs Client-Side Lua into your client.", (string[] args) => { - ContentPackage luaCsPackage = LuaCsSetup.GetPackage(); + ContentPackage luaPackage = LuaCsSetup.GetPackage("LuaForBarotraumaUnstable"); - if (luaCsPackage == null) + if (luaPackage == null) { GameMain.Server.SendChatMessage("Couldn't find the LuaCsForBarotrauma package.", ChatMessageType.ServerMessageBox); return; @@ -1267,7 +1267,7 @@ namespace Barotrauma try { - string path = Path.GetDirectoryName(luaCsPackage.Path); + string path = Path.GetDirectoryName(luaPackage.Path); string[] filesToCopy = new string[] { @@ -1297,7 +1297,7 @@ namespace Barotrauma File.Copy(Path.Combine(path, "Binary", file), file, true); } - File.WriteAllText(LuaCsSetup.VERSION_FILE, luaCsPackage.ModVersion); + File.WriteAllText(LuaCsSetup.VERSION_FILE, luaPackage.ModVersion); } catch (UnauthorizedAccessException e) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs index c4038c0a2..82e65fe6d 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs @@ -43,11 +43,11 @@ namespace Barotrauma } - public static ContentPackage GetPackage() + public static ContentPackage GetPackage(Identifier name) { foreach (ContentPackage package in ContentPackageManager.LocalPackages) { - if (package.NameMatches(new Identifier("LuaCsForBarotraumaUnstable"))) + if (package.NameMatches(name)) { return package; } @@ -55,7 +55,7 @@ namespace Barotrauma foreach (ContentPackage package in ContentPackageManager.AllPackages) { - if (package.NameMatches(new Identifier("LuaCsForBarotraumaUnstable"))) + if (package.NameMatches(name)) { return package; } @@ -302,8 +302,6 @@ namespace Barotrauma LuaScriptLoader = new LuaScriptLoader(); LuaScriptLoader.ModulePaths = new string[] { }; - NetScriptLoader = new CsScriptLoader(this); - LuaCustomConverters.RegisterAll(); lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug); @@ -358,21 +356,27 @@ namespace Barotrauma // LuaDocs.GenerateDocsAll(); + ContentPackage csPackage = GetPackage("CsForBarotrauma"); - NetScriptLoader.SearchFolders(); - if (NetScriptLoader == null) throw new Exception("LuaCsSetup was not properly initialized."); - try + + if (csPackage != null) { - var modTypes = NetScriptLoader.Compile(); - modTypes.ForEach(t => t.GetConstructor(new Type[] { })?.Invoke(null)); - } - catch (Exception ex) - { - HandleException(ex, exceptionType: ExceptionType.CSharp); + NetScriptLoader = new CsScriptLoader(this); + + NetScriptLoader.SearchFolders(); + try + { + var modTypes = NetScriptLoader.Compile(); + modTypes.ForEach(t => t.GetConstructor(new Type[] { })?.Invoke(null)); + } + catch (Exception ex) + { + HandleException(ex, exceptionType: ExceptionType.CSharp); + } } - ContentPackage luaCsPackage = GetPackage(); + ContentPackage luaPackage = GetPackage("LuaForBarotraumaUnstable"); if (File.Exists(LUASETUP_FILE)) { @@ -385,9 +389,9 @@ namespace Barotrauma HandleException(e); } } - else if (luaCsPackage != null) + else if (luaPackage != null) { - string path = Path.GetDirectoryName(luaCsPackage.Path); + string path = Path.GetDirectoryName(luaPackage.Path); try {