diff --git a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs index ecf7d8dd5..e27829e50 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs @@ -660,12 +660,6 @@ namespace Barotrauma return; } - bool luaCsEnabled = true; - if (args.Length > 3) - { - bool.TryParse(args[3], out luaCsEnabled); - } - GameMain.MainMenuScreen.QuickStart(fixedSeed: false, subName, difficulty, levelGenerationParams); }, getValidArgs: () => new[] { SubmarineInfo.SavedSubmarines.Select(s => s.Name).Distinct().OrderBy(s => s).ToArray() })); @@ -4222,24 +4216,6 @@ namespace Barotrauma NewMessage("Minimum main path width: " + (Level.Loaded.LevelData?.MinMainPathWidth?.ToString() ?? "unknown")); } }); - - commands.Add(new Command("cl_lua", $"cl_lua: Runs a string on the client.", (string[] args) => - { - if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands)) - { - ThrowError("Command not permitted."); - return; - } - - if (LuaCsSetup.Instance.CurrentRunState != RunState.Running) - { - ThrowError("LuaCs not initialized, use the console command cl_reloadluacs to force initialization."); - return; - } - - var result = LuaCsSetup.Instance.LuaScriptManagementService.DoString(string.Join(" ", args)); - LuaCsSetup.Instance.Logger.LogResults(result.ToResult()); - })); } private static void ReloadWearables(Character character, int variant = 0) diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index 6a04212ff..320e98b95 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1288,37 +1288,6 @@ namespace Barotrauma GameMain.NetLobbyScreen.LevelSeed = string.Join(" ", args); })); - - commands.Add(new Command("lua", "lua: Runs a string.", (string[] args) => - { - var result = LuaCsSetup.Instance.LuaScriptManagementService.DoString(string.Join(" ", args)); - LuaCsSetup.Instance.Logger.LogResults(result.ToResult()); - })); - - commands.Add(new Command("reloadlua|reloadcs|reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) => - { - //GameMain.LuaCs.Initialize(); - LuaCsSetup.Instance.EventService.PublishEvent(sub => sub.OnReloadAllPackages()); - })); - - commands.Add(new Command("toggleluadebug", "Toggles the MoonSharp Debug Server.", (string[] args) => - { - int port = 41912; - - if (args.Length > 0) - { - int.TryParse(args[0], out port); - } - - throw new NotImplementedException(); - //GameMain.LuaCs.ToggleDebugger(port); - })); - - commands.Add(new Command("install_cl_lua|install_cl|install_cl_cs|install_cl_luacs", "Installs Client-Side LuaCs into your client.", (string[] args) => - { - LuaCsInstaller.Install(); - })); - commands.Add(new Command("randomizeseed", "randomizeseed: Toggles level seed randomization on/off.", (string[] args) => { GameMain.Server.ServerSettings.RandomizeSeed = !GameMain.Server.ServerSettings.RandomizeSeed; diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/LuaScriptManagementService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/LuaScriptManagementService.cs index 4ae22dad6..b3770a90a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/LuaScriptManagementService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/LuaScriptManagementService.cs @@ -84,15 +84,35 @@ class LuaScriptManagementService : ILuaScriptManagementService, ILuaDataService _luaCsTimer = luaCsTimer; RegisterLuaEvents(); + RegisterConsoleCommands(_commandsService); } private void RegisterConsoleCommands(IConsoleCommandsService commands) { +#if CLIENT commands.RegisterCommand("cl_reloadlua|cl_reloadcs|cl_reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) => { LuaCsSetup.Instance.EventService.PublishEvent(sub => sub.OnReloadAllPackages()); }); + commands.RegisterCommand("cl_lua", $"cl_lua: Runs a string on the client.", (string[] args) => + { + if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands)) + { + DebugConsole.ThrowError("Command not permitted."); + return; + } + + if (LuaCsSetup.Instance.CurrentRunState != RunState.Running) + { + DebugConsole.ThrowError("LuaCs not initialized, use the console command cl_reloadluacs to force initialization."); + return; + } + + var result = LuaCsSetup.Instance.LuaScriptManagementService.DoString(string.Join(" ", args)); + LuaCsSetup.Instance.Logger.LogResults(result.ToResult()); + }); + commands.RegisterCommand("cl_toggleluadebug", "Toggles the MoonSharp Debug Server.", (string[] args) => { int port = 41912; @@ -105,6 +125,39 @@ class LuaScriptManagementService : ILuaScriptManagementService, ILuaDataService throw new NotImplementedException(); //GameMain.LuaCs.ToggleDebugger(port); }); + +#elif SERVER + commands.RegisterCommand("lua", "lua: Runs a string.", (string[] args) => + { + var result = LuaCsSetup.Instance.LuaScriptManagementService.DoString(string.Join(" ", args)); + LuaCsSetup.Instance.Logger.LogResults(result.ToResult()); + }); + + commands.RegisterCommand("reloadlua|reloadcs|reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) => + { + LuaCsSetup.Instance.EventService.PublishEvent(sub => sub.OnReloadAllPackages()); + }); + + commands.RegisterCommand("toggleluadebug", "Toggles the MoonSharp Debug Server.", (string[] args) => + { + int port = 41912; + + if (args.Length > 0) + { + int.TryParse(args[0], out port); + } + + throw new NotImplementedException(); + //GameMain.LuaCs.ToggleDebugger(port); + }); +#endif + +#if SERVER + commands.RegisterCommand("install_cl_lua|install_cl|install_cl_cs|install_cl_luacs", "Installs Client-Side LuaCs into your client.", (string[] args) => + { + LuaCsInstaller.Install(); + }); +#endif } public bool IsDisposed { get; private set; }