From f09e10ae49bed761b7afc2331db8643693d2862e Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 13 Sep 2024 02:51:36 +0100 Subject: [PATCH] document register_command --- .../core/register_command.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/worldeditadditions_core/core/register_command.lua b/worldeditadditions_core/core/register_command.lua index 6ae81fb..2c07293 100644 --- a/worldeditadditions_core/core/register_command.lua +++ b/worldeditadditions_core/core/register_command.lua @@ -5,7 +5,7 @@ -- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██ --- WorldEditAdditions chat command registration --- @namespace worldeditadditions_core +-- @module worldeditadditions_core local wea_c = worldeditadditions_core local run_command = dofile(wea_c.modpath.."/core/run_command.lua") @@ -13,7 +13,19 @@ local function log_error(cmdname, error_message) minetest.log("error", "register_command("..cmdname..") error: "..error_message) end ---- TODO: Document this function + +--- Registers a new WorldEditAdditions chat command. +-- @param cmdname string The name of the command to register. +-- @param options table A table of options for the command: +-- - `params` (string) A textual description of the parameters the command takes. +-- - `description` (string) A description of the command. +-- - `privs` (`{someprivilege=true, ....}`) The privileges required to use the command. +-- - `require_pos` (number) The number of positions required for the command. +-- - `parse` (function) A function that parses the raw param_text into proper input arguments to be passed to `nodes_needed` and `func`. +-- - `nodes_needed` (function) A function that returns the number of nodes the command could potential change given the parsed input arguments. +-- - `func` (function) The function to execute when the command is run. +-- - `override=false` (boolean) Whether to override an existing command with the same name. +-- @return boolean True if the command was registered successfully, false otherwise. local function register_command(cmdname, options) ---