From b3d0fbeb5d9f417d07d30e3964122be998ebb8dd Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:17:43 -0300 Subject: [PATCH] Add cfg_setvalue command --- .../SharedSource/DebugConsole.cs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs index 05444468b..22597e938 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs @@ -2311,6 +2311,55 @@ namespace Barotrauma NewMessage($"Start item set changed to \"{AutoItemPlacer.DefaultStartItemSet}\""); }, isCheat: false)); + commands.Add(new Command("cfg_setvalue", "cfg_setvalue [Content Package] [InternalName] [ValueString]: sets a config.", (string[] args) => + { + if (args.Length < 1) + { + ThrowError("Please specify the name of the package to set the config."); + return; + } + + if (args.Length < 2) + { + ThrowError("Please specify the name of the config."); + return; + } + + if (args.Length < 3) + { + ThrowError("Please specify the value to set the config to."); + return; + } + + var package = ContentPackageManager.RegularPackages.FirstOrDefault(p => p.Name == args[0]); + if (package == null) + { + ThrowError($"Could not find the package {args[0]}!"); + return; + } + + string internalName = args[1]; + string valueString = args[2]; + + if (!GameMain.LuaCs.ConfigService.TryGetConfig(package, internalName, out LuaCs.Data.ISettingBase setting)) + { + ThrowError($"Could not get config with name {internalName}"); + return; + } + + if (setting.TrySetValue(valueString)) + { + NewMessage($"Set config {internalName} value to {valueString}", Color.Green); + } + else + { + ThrowError($"Failed to set config value"); + } + }, getValidArgs: () => new[] + { + ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray() + })); + //"dummy commands" that only exist so that the server can give clients permissions to use them //TODO: alphabetical order? commands.Add(new Command("control", "control [character name]: Start controlling the specified character (client-only).", null, () =>