added a way to create console commands
This commit is contained in:
@@ -288,6 +288,20 @@ namespace Barotrauma
|
||||
}
|
||||
return enabledPackages;
|
||||
}
|
||||
|
||||
public void AddCommand(string name, string help, object onExecute, object getValidArgs = null, bool isCheat = false)
|
||||
{
|
||||
DebugConsole.Commands.Add(new DebugConsole.Command(name, help, (string[] arg1) => { env.CallFunction(onExecute, new object[] { arg1 }); },
|
||||
() => {
|
||||
var result = env.CallFunction(getValidArgs, new object[] { });
|
||||
if (result == null || !(result is string[][])) { return null; }
|
||||
return (string[][])result;
|
||||
|
||||
}, isCheat = false));
|
||||
}
|
||||
|
||||
public void AssignOnExecute(string names, object onExecute) => DebugConsole.AssignOnExecute(names, (string[] a) => { env.CallFunction(onExecute, new object[] { a }); });
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace Barotrauma
|
||||
lua.Globals["DeliveryMethod"] = UserData.CreateStatic<DeliveryMethod>();
|
||||
lua.Globals["ClientPacketHeader"] = UserData.CreateStatic<ClientPacketHeader>();
|
||||
lua.Globals["ServerPacketHeader"] = UserData.CreateStatic<ServerPacketHeader>();
|
||||
|
||||
|
||||
#if SERVER
|
||||
|
||||
#elif CLIENT
|
||||
|
||||
Reference in New Issue
Block a user