From fa9b511e339f6e48d795da9c8ee150bd8c558398 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 16 May 2022 23:40:03 +0100 Subject: [PATCH] core: finish initial register_command --- worldeditadditions_core/core/register_command.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/worldeditadditions_core/core/register_command.lua b/worldeditadditions_core/core/register_command.lua index c06094d..0e47e31 100644 --- a/worldeditadditions_core/core/register_command.lua +++ b/worldeditadditions_core/core/register_command.lua @@ -5,6 +5,9 @@ -- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██ -- WorldEditAdditions chat command registration +local we_c = worldeditadditions_core + +local run_command = dofile(we_c.modpath.."/core/run_command.lua") local function log_error(cmdname, error_message) minetest.log("error", "register_command("..cmdname..") error: "..error_message) @@ -30,6 +33,10 @@ local function register_command(cmdname, options) log_error(cmdname, "The func option is not a function.") return false end + if we_c.registered_commands[cmdname] and options.override ~= true then + log_error(cmdname, "A WorldEditAdditions command with that name is registered, but the option override is not set to true.") + return false + end --- @@ -37,7 +44,7 @@ local function register_command(cmdname, options) --- if not options.privs then options.privs = {} end if not options.require_pos then options.require_pos = 0 end - if not options.nodes_needed then options.nodes_needed = function() return 0 end + if not options.nodes_needed then options.nodes_needed = function() return 0 end end --- -- 3: Registration @@ -47,8 +54,8 @@ local function register_command(cmdname, options) description = options.description, privs = options.privs, func = function(player_name, paramtext) - -- TODO: Fill this in + run_command(cmdname, player_name, paramtext) end - }) + we_c.registered_commands[cmdname] = options end