Commands
Command Manager
The Command Manager is a tool, which provides help creating ingame commands, managing them and executing them.
To access the Command Manager, you can write the following code:
let CommandManager = MooMoo.CommandManager;
You can register a command like this:
CommandManager.registerCommand("test", (Command, args) => {
// reply to the Command with a chat message
Command.reply("Hello, world!");
// do stuff with the arguments
let firstArg = args[0];
console.log(firstArg);
})
By writing this code, the commandManager will register a new command called "test", and whenever the player types "{prefix}test" in chat, the command will be executed.
The Command
object includes the function that executes it, and also the function that replies to the command.
The args
object is an array of arguments that the player has passed to the command.
You can change the prefix for the commands by writing the following code:
CommandManager.setPrefix("!");
This will change the prefix to "!".
The commands will get executed whenever the player types in a chat message starting with the prefix.