Fix debug console commands
This commit is contained in:
@@ -660,12 +660,6 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool luaCsEnabled = true;
|
|
||||||
if (args.Length > 3)
|
|
||||||
{
|
|
||||||
bool.TryParse(args[3], out luaCsEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMain.MainMenuScreen.QuickStart(fixedSeed: false, subName, difficulty, levelGenerationParams);
|
GameMain.MainMenuScreen.QuickStart(fixedSeed: false, subName, difficulty, levelGenerationParams);
|
||||||
|
|
||||||
}, getValidArgs: () => new[] { SubmarineInfo.SavedSubmarines.Select(s => s.Name).Distinct().OrderBy(s => s).ToArray() }));
|
}, 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"));
|
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)
|
private static void ReloadWearables(Character character, int variant = 0)
|
||||||
|
|||||||
@@ -1288,37 +1288,6 @@ namespace Barotrauma
|
|||||||
GameMain.NetLobbyScreen.LevelSeed = string.Join(" ", args);
|
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<IEventReloadAllPackages>(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) =>
|
commands.Add(new Command("randomizeseed", "randomizeseed: Toggles level seed randomization on/off.", (string[] args) =>
|
||||||
{
|
{
|
||||||
GameMain.Server.ServerSettings.RandomizeSeed = !GameMain.Server.ServerSettings.RandomizeSeed;
|
GameMain.Server.ServerSettings.RandomizeSeed = !GameMain.Server.ServerSettings.RandomizeSeed;
|
||||||
|
|||||||
+53
@@ -84,15 +84,35 @@ class LuaScriptManagementService : ILuaScriptManagementService, ILuaDataService
|
|||||||
_luaCsTimer = luaCsTimer;
|
_luaCsTimer = luaCsTimer;
|
||||||
|
|
||||||
RegisterLuaEvents();
|
RegisterLuaEvents();
|
||||||
|
RegisterConsoleCommands(_commandsService);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterConsoleCommands(IConsoleCommandsService commands)
|
private void RegisterConsoleCommands(IConsoleCommandsService commands)
|
||||||
{
|
{
|
||||||
|
#if CLIENT
|
||||||
commands.RegisterCommand("cl_reloadlua|cl_reloadcs|cl_reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) =>
|
commands.RegisterCommand("cl_reloadlua|cl_reloadcs|cl_reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) =>
|
||||||
{
|
{
|
||||||
LuaCsSetup.Instance.EventService.PublishEvent<IEventReloadAllPackages>(sub => sub.OnReloadAllPackages());
|
LuaCsSetup.Instance.EventService.PublishEvent<IEventReloadAllPackages>(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) =>
|
commands.RegisterCommand("cl_toggleluadebug", "Toggles the MoonSharp Debug Server.", (string[] args) =>
|
||||||
{
|
{
|
||||||
int port = 41912;
|
int port = 41912;
|
||||||
@@ -105,6 +125,39 @@ class LuaScriptManagementService : ILuaScriptManagementService, ILuaDataService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
//GameMain.LuaCs.ToggleDebugger(port);
|
//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<IEventReloadAllPackages>(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; }
|
public bool IsDisposed { get; private set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user