diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index 3ce26a0ece..2656b8a0db 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -25,9 +25,9 @@ mcl_commands.types = { json = "(.+)", } -function mcl_commands.register_command(name, func, def) +function mcl_commands.register_command(name, def) def = def or {} - local cmd = mcl_commands.build(func, def) + local cmd = mcl_commands.build(name, def) if minetest.registered_chatcommands[name] then error("[mcl_commands] Failed to register command: ["..name.."] command already existing! Use mcl_commands.overide_command() if you want to overide existing command") end @@ -36,9 +36,9 @@ function mcl_commands.register_command(name, func, def) return cmd end -function mcl_commands.overide_command(name, func, def) +function mcl_commands.overide_command(name, def) def = def or {} - local cmd = mcl_commands.build(func, def) + local cmd = mcl_commands.build(name, def) if minetest.registered_chatcommands[name] then minetest.unregister_chatcommand(name) end @@ -61,7 +61,7 @@ end local dprint = function() end -function mcl_commands.build(func, def) +function mcl_commands.build(def) local cmd = { _subs = {} } @@ -174,8 +174,8 @@ function mcl_commands.build(func, def) table.insert(self._subs, sub) end - if func then - func(cmd) + if def.func then + def.func(cmd) end cmd.func = function(name, param) @@ -218,13 +218,17 @@ function mcl_commands.build(func, def) else local missing_privs_str = "" for i = 1, #missing_privs do - missing_privs_str = missing_privs_str..missing_privs[i].." " + if not i == #missing_privs then + missing_privs_str = missing_privs_str..missing_privs[i].." " + else + missing_privs_str = missing_privs_str..missing_privs[i] + end end return false, "You don't have permission to run this command (missing privilege: "..missing_privs_str..")" --TODO:replace message end end end - return false, "Invalid command" + return false, "Invalid parameters: " end if not def.params then def.params = "" diff --git a/mods/MISC/mcl_commands/say.lua b/mods/MISC/mcl_commands/say.lua index 2b01a7e935..f98f906a0f 100644 --- a/mods/MISC/mcl_commands/say.lua +++ b/mods/MISC/mcl_commands/say.lua @@ -4,15 +4,31 @@ minetest.register_privilege("announce", { description = S("Can use /say"), give_to_singleplayer = false, }) -minetest.register_chatcommand("say", { - params = S(""), - description = S("Send a message to every player"), - privs = {announce=true}, - func = function(name, param) - if not param then - return false, S("Invalid usage, see /help say.") - end - minetest.chat_send_all(("["..name.."] "..param)) - return true + +mcl_commands.register_command("say", function(cmd) + cmd:sub(":message:text", { + func = function(name, message) + minetest.chat_send_all(("["..name.."] "..message)) + return true + end}) end, + { + description = S("Send a message to every player"), + params = S(""), + privs = { + announce = true, + } +}) + +mcl_commands.register_command("say", { + func = function(cmd) + cmd:sub(":message:text", { + func = function(name, message) + minetest.chat_send_all(("["..name.."] "..message)) + return true + end}) + end, + description = S("Send a message to every player"), + params = S(""), + privs = {announce = true}, }) \ No newline at end of file diff --git a/mods/MISC/mcl_commands/title.lua b/mods/MISC/mcl_commands/title.lua index 30e562c1f2..4a8e4825ba 100644 --- a/mods/MISC/mcl_commands/title.lua +++ b/mods/MISC/mcl_commands/title.lua @@ -103,41 +103,40 @@ function mcl_title.reset(playername) end end -mcl_commands.register_command("title", function(cmd) - cmd:sub(":name:username title :params:json", { - func = function(name, target, json) - return mcl_title.set(target, "title", json) - end, - }) - cmd:sub(":name:username subtitle :params:json", { - func = function(name, target, json) - return mcl_title.set(target, "subtitle", json) - end, - }) - cmd:sub(":name:username actionbar :params:json", { - func = function(name, target, json) - return mcl_title.set(target, "actionbar", json) - end, - }) - cmd:sub(":name:username times :fadeIn:int :stay:int :fadeOut:int", { - func = function(name, target, fadeIn, stay, fadeOut) --WIP - return mcl_title.times(target, fadeIn, stay, fadeOut) - end, - }) - cmd:sub(":name:username clear", { - func = function(name, target) - return mcl_title.clear(target) - end, - }) - cmd:sub(":name:username reset", { - func = function(name, target) - return mcl_title.reset(target) - end, - }) -end, { +mcl_commands.register_command("title", { + func = function(cmd) + cmd:sub(":name:username title :params:json", { + func = function(name, target, json) + return mcl_title.set(target, "title", json) + end, + }) + cmd:sub(":name:username subtitle :params:json", { + func = function(name, target, json) + return mcl_title.set(target, "subtitle", json) + end, + }) + cmd:sub(":name:username actionbar :params:json", { + func = function(name, target, json) + return mcl_title.set(target, "actionbar", json) + end, + }) + cmd:sub(":name:username times :fadeIn:int :stay:int :fadeOut:int", { + func = function(name, target, fadeIn, stay, fadeOut) --WIP + return mcl_title.times(target, fadeIn, stay, fadeOut) + end, + }) + cmd:sub(":name:username clear", { + func = function(name, target) + return mcl_title.clear(target) + end, + }) + cmd:sub(":name:username reset", { + func = function(name, target) + return mcl_title.reset(target) + end, + }) + end, description = "Controls text displayed on the screen.", params = " command ", - privs = { - server = true, - } + privs = {server = true}, }) \ No newline at end of file