Added legacy overload of AddCommand for mod compat.

This commit is contained in:
MapleWheels
2026-04-13 12:02:16 -04:00
parent a40e54f4e4
commit addd3f7a45
@@ -446,6 +446,26 @@ namespace Barotrauma.LuaCs
); );
} }
public void AddCommand(string name, LuaCsAction onExecute, LuaCsFunc getValidArgs = null, bool isCheat = false)
{
_consoleCommands.RegisterCommand(name, "",
(string[] args) =>
{
onExecute(new object[] { args });
},
() =>
{
if (getValidArgs == null) { return null; }
var validArgs = getValidArgs();
if (validArgs is DynValue luaValue)
{
return luaValue.ToObject<string[][]>();
}
return (string[][])validArgs;
}
);
}
public bool IsDisposed => throw new NotImplementedException(); public bool IsDisposed => throw new NotImplementedException();
public void AssignOnExecute(string names, object onExecute) => DebugConsole.AssignOnExecute(names, (string[] args) => public void AssignOnExecute(string names, object onExecute) => DebugConsole.AssignOnExecute(names, (string[] args) =>