diff --git a/mods/CORE/mcl_commands/alias.lua b/mods/CORE/mcl_commands/alias.lua index 5c9ee9f3ce..bbe36b9e68 100644 --- a/mods/CORE/mcl_commands/alias.lua +++ b/mods/CORE/mcl_commands/alias.lua @@ -1,30 +1,7 @@ -local S = minetest.get_translator(minetest.get_current_modname()) - -local function register_chatcommand_alias(alias, cmd) - local def = minetest.chatcommands[cmd] - minetest.register_chatcommand(alias, def) -end - -local function rename_chatcommand(newname, cmd) - local def = minetest.chatcommands[cmd] - minetest.register_chatcommand(newname, def) - minetest.unregister_chatcommand(cmd) -end - -if minetest.settings:get_bool("mcl_builtin_commands_overide", true) then - register_chatcommand_alias("?", "help") - register_chatcommand_alias("pardon", "unban") - rename_chatcommand("stop", "shutdown") - register_chatcommand_alias("tell", "msg") - register_chatcommand_alias("w", "msg") - register_chatcommand_alias("tp", "teleport") - rename_chatcommand("clear", "clearinv") - - minetest.register_chatcommand("banlist", { - description = S("List bans"), - privs = minetest.chatcommands["ban"].privs, - func = function(name) - return true, S("Ban list: @1", minetest.get_ban_list()) - end, - }) -end \ No newline at end of file +mcl_commands.alias_command("?", "help", false) +mcl_commands.alias_command("pardon", "unban", false) +mcl_commands.rename_command("stop", "shutdown", false) +mcl_commands.alias_command("tell", "msg", false) +mcl_commands.alias_command("w", "msg", false) +mcl_commands.alias_command("tp", "teleport", false) +mcl_commands.rename_command("clear", "clearinv", false) \ No newline at end of file diff --git a/mods/CORE/mcl_commands/api.lua b/mods/CORE/mcl_commands/api.lua new file mode 100644 index 0000000000..52cf87e8f7 --- /dev/null +++ b/mods/CORE/mcl_commands/api.lua @@ -0,0 +1,40 @@ +mcl_commands.types = { + bool = {}, + int = {}, + float = {}, + word = {}, + text = {}, + pos = {}, + target = {}, + playername = {}, +} + +function mcl_commands.register_complex_command() +end + +function mcl_commands.register_basic_command() +end + +function mcl_commands.alias_command(alias, original_name, bypass_setting) + if minetest.settings:get_bool("mcl_builtin_commands_overide", true) or bypass_setting then + local def = minetest.registered_chatcommands[cmd] + minetest.register_chatcommand(alias, def) + minetest.log("action", string.format("[mcl_commands] Aliasing [%s] command to [%s]", original_name, alias)) + else + minetest.log("action", string.format("[mcl_commands] Aliasing [%s] command to [%s] skipped according to setting", original_name, alias)) + end +end + +function mcl_commands.rename_command(new_name, original_name, bypass_setting) + if minetest.settings:get_bool("mcl_builtin_commands_overide", true) or bypass_setting then + local def = minetest.registered_chatcommands[cmd] + minetest.register_chatcommand(newname, def) + minetest.unregister_chatcommand(cmd) + minetest.log("action", string.format("[mcl_commands] Renaming [%s] command to [%s]", original_name, new_name)) + else + minetest.log("action", string.format("[mcl_commands] Renaming [%s] command to [%s] skipped according to setting", original_name, new_name)) + end +end + +function mcl_commands.get_target_selector(target_selector) +end \ No newline at end of file diff --git a/mods/CORE/mcl_commands/init.lua b/mods/CORE/mcl_commands/init.lua index 97eee3abc3..d47758e622 100644 --- a/mods/CORE/mcl_commands/init.lua +++ b/mods/CORE/mcl_commands/init.lua @@ -1,5 +1,9 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) +mcl_commands = {} + +dofile(modpath.."/api.lua") + dofile(modpath.."/register/kill.lua") dofile(modpath.."/register/setblock.lua") dofile(modpath.."/register/seed.lua") @@ -7,5 +11,6 @@ dofile(modpath.."/register/summon.lua") dofile(modpath.."/register/say.lua") dofile(modpath.."/register/list.lua") dofile(modpath.."/register/sound.lua") +dofile(modpath.."/register/banlist.lua") dofile(modpath.."/alias.lua") \ No newline at end of file diff --git a/mods/CORE/mcl_commands/register/banlist.lua b/mods/CORE/mcl_commands/register/banlist.lua new file mode 100644 index 0000000000..5fcba602c6 --- /dev/null +++ b/mods/CORE/mcl_commands/register/banlist.lua @@ -0,0 +1,9 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +minetest.register_chatcommand("banlist", { + description = S("List bans"), + privs = minetest.registered_chatcommands["ban"].privs, + func = function(name) + return true, S("Ban list: @1", minetest.get_ban_list()) + end, +}) \ No newline at end of file