From 270820125df0a247c47425eefe3bc9e56bf96686 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sat, 11 Mar 2023 23:10:48 +0000 Subject: [PATCH] Add in a default for improved clearmobs command. --- mods/ENTITIES/mcl_mobs/api.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 282aab2b3..8342a037d 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -537,12 +537,14 @@ end) minetest.register_chatcommand("clearmobs",{ privs={maphack=true}, - params = "|| |", + params = "[||] [|]", description=S("Removes specified spawned mobs except nametagged and tamed ones. For param2, use nametagged to remove those with a nametag, or range for all mobs in a distance of the current player to be removed."), - func=function(n,param) + func=function(player, param) + local default = false if not param or param == "" then - minetest.log("Incorrect usage. For more information please type: /help clearmobs") - return + default = true + minetest.chat_send_player(player, + S("Default usage. Clearing hostile mobs. For more options please type: /help clearmobs")) end local mob, unsafe = param:match("^([%w]+)[ ]?([%w%d]*)$") @@ -562,8 +564,12 @@ minetest.register_chatcommand("clearmobs",{ end --minetest.log ("mob: [" .. mob .. "]") else - --minetest.log("No valid second param") - return + --minetest.log("No valid first param") + if default then + --minetest.log("Use default") + mob_type = "monster" + end + --return end -- Param 2 resolve @@ -577,7 +583,7 @@ minetest.register_chatcommand("clearmobs",{ if num then range = num end end - local p = minetest.get_player_by_name(n) + local p = minetest.get_player_by_name(player) for _,o in pairs(minetest.luaentities) do if o and o.is_mob then