fix AddCommand arguments being wrong and fixed getValidArgs not doing anything
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user