From e5443bc3ce291df72d6a06dc29125a0e9d5868db Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Mon, 2 Aug 2021 18:54:33 -0700 Subject: [PATCH] check (maybe working?) --- worldeditadditions_core/register/check.lua | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/worldeditadditions_core/register/check.lua b/worldeditadditions_core/register/check.lua index 1dfb87b..5c08285 100644 --- a/worldeditadditions_core/register/check.lua +++ b/worldeditadditions_core/register/check.lua @@ -1,14 +1,26 @@ -function worldeditadditions_core.register_command(def) - local def = table.copy(def) - assert(name and #name > 0) - assert(def.privs) - def.require_pos = def.require_pos or 0 - assert(def.require_pos >= 0 and def.require_pos < 3) - if def.params == "" and not def.parse then - def.parse = function(params_text) return true end - else - assert(def.parse) +function worldeditadditions_core.check_command(name, def) + if not (name and #name > 0) then + return false, "Error: No command name." end - assert(def.nodes_needed == nil or type(def.nodes_needed) == "function") - assert(def.func) + if not def.privs then + return false, "Error: privs is nill. Expected table." + end + def.require_pos = def.require_pos or 0 + if not (def.require_pos >= 0 and def.require_pos < 3) then + return false, "Error: require_pos must be greater than -1 and less than 3." + end + if not def.parse then + if def.params == "" then + def.parse = function(params_text) return true end + else + return false, "Error: parse function is invalid." + end + end + if not (def.nodes_needed == nil or type(def.nodes_needed) == "function") then + return false, "Error: nodes_needed must be nil or function." + end + if not def.func then + return false, "Error: main function is invalid." + end + return true end