From 884097a8e5bf42a58261733cadf0fb5a460a5055 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 9 Mar 2021 00:00:21 +0100 Subject: [PATCH] add API documentation for mcl_commands --- mods/CORE/mcl_commands/API.md | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 mods/CORE/mcl_commands/API.md diff --git a/mods/CORE/mcl_commands/API.md b/mods/CORE/mcl_commands/API.md new file mode 100644 index 000000000..cbc634dfb --- /dev/null +++ b/mods/CORE/mcl_commands/API.md @@ -0,0 +1,59 @@ +# API documentation of mcl_commands + +The mcl_commands API allows you to register and overide complex commands. +This mod is derivated from ChatCommandBuilder by rubenwardy + +## Technical differences from ChatCommandBuilder + +* subcommand aditional specific privs +* new types: `json` an maybe more in the future + + +## Public Functions + +### `mcl_commands.register_command("exemple", def)` + +This is a function which is called when an item is dispensed by the dispenser. +These are the parameters: + +``` +mcl_commands.register_command("exemple", { + func = function(cmd) --function executed on registration + cmd:sub(":name:username title :params:json", { --create a new subcommand called "title" with defined patterns + func = function(name, target, json) + return a_cool_function(target, json) --function executed if the params match the patterns + end, + privs = {settime = true}, --subcommand aditional specific privs + }) + end, + description = "Controls text displayed on the screen.", --the description of the command + params = " command ", --very basic explaination of the syntax of the command (will be semi-automatic in the future) + privs = {server = true}, --global privs +}) +``` + +Register a complex chatcommand. If a chat command with the same name is already registered, the program will fail. + +### `mcl_commands.overide_command("exemple", def)` + +Same as above but will overide existing command. + +### paterns + +mcl_commands adds many types for patterns +If not specified, a value will be by default with the word pattern. + +* pos value must be pos +* text value must be text WARNING: this pattern must be the last pattern of the subcommand!! +* number value must be number +* int value must be integer +* word value must be word +* alpha value must be alphanumeric +* modname value must be a valid modname +* alphascore +* alphanumeric +* username: value must be a valid username +* json: value must be a json string (will be parsed automaticaly) + +TODO: +* color value must be a color string or a valid named color