fix AddCommand arguments being wrong and fixed getValidArgs not doing anything

This commit is contained in:
Evil Factory
2022-05-28 15:06:22 -03:00
parent 60b8cd981d
commit 6ddfc985d3
@@ -349,14 +349,13 @@ namespace Barotrauma
public void AddCommand(string name, string help, LuaCsAction onExecute, LuaCsFunc getValidArgs = null, bool isCheat = false) public void AddCommand(string name, string help, LuaCsAction onExecute, LuaCsFunc getValidArgs = null, bool isCheat = false)
{ {
var cmd = new DebugConsole.Command(name, help, (string[] arg1) => { onExecute(arg1); }, var cmd = new DebugConsole.Command(name, help, (string[] arg1) => { onExecute(new object[] { arg1 }); },
() => () =>
{ {
if (getValidArgs == null) return null; if (getValidArgs == null) { return null; }
var obj = getValidArgs(); var obj = getValidArgs();
if (obj is LuaResult res) obj = res.Object(); if (obj is LuaResult lr) { return lr.DynValue().ToObject<string[][]>(); }
if (obj is string[][]) return (string[][])obj; return (string[][])obj;
return null;
}, isCheat); }, isCheat);
luaAddedCommand.Add(cmd); luaAddedCommand.Add(cmd);