Commands Class |
Namespace: spaar.ModLoader
public static class Commands
The Commands type exposes the following members.
Name | Description | |
---|---|---|
DoesCommandExist |
Checks whether a command currently exists (is registered).
| |
HandleCommand |
Handle an entered command.
Arguments are parsed and then the callback corresponding to the command
is called.
| |
RegisterCommand |
Register a console command.
The passed callback will be called when the user enters the command in
the console.
If the same command was previously registered by the same mod,
the old one will be updated instead of a new one being registered.
| |
RegisterHelpMessage |
Register a help message for your mod to be displayed with the 'help' command.
This should give a general overview, to give specific information about
a command, use the helpText parameter of RegisterCommand.
|
Commands.RegisterCommand("myCommand", MyCallback);
private string MyCallback(string[] args, IDictionary<string, string> namedArgs) { if (args.Length != 2) { return "Usage: myCommand <param1> <param2>"; } return "You passed " + args[0] + " and " + args[1]; }
Commands.RegisterCommand("myCommand", (args, namedArgs) => { if (args.Length != 2) { return "Usage: myCommand <param1> <param2>"; } return "You passed " + args[0] + " and " + args[1]; });
myCommand arg1 "second unnamed arg" --namedArg1 value1 --namedArg2 "second value"