Add in a default for improved clearmobs command.

This commit is contained in:
ancientmarinerdev 2023-03-11 23:10:48 +00:00 committed by Gitea
parent fc7eb135e6
commit 270820125d
1 changed files with 13 additions and 7 deletions

View File

@ -537,12 +537,14 @@ end)
minetest.register_chatcommand("clearmobs",{ minetest.register_chatcommand("clearmobs",{
privs={maphack=true}, privs={maphack=true},
params = "<all>|<hostile/passive>|<name> <nametagged>|<range>", params = "[<all>|<hostile/passive>|<name>] [<nametagged>|<range>]",
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."), 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 if not param or param == "" then
minetest.log("Incorrect usage. For more information please type: /help clearmobs") default = true
return minetest.chat_send_player(player,
S("Default usage. Clearing hostile mobs. For more options please type: /help clearmobs"))
end end
local mob, unsafe = param:match("^([%w]+)[ ]?([%w%d]*)$") local mob, unsafe = param:match("^([%w]+)[ ]?([%w%d]*)$")
@ -562,8 +564,12 @@ minetest.register_chatcommand("clearmobs",{
end end
--minetest.log ("mob: [" .. mob .. "]") --minetest.log ("mob: [" .. mob .. "]")
else else
--minetest.log("No valid second param") --minetest.log("No valid first param")
return if default then
--minetest.log("Use default")
mob_type = "monster"
end
--return
end end
-- Param 2 resolve -- Param 2 resolve
@ -577,7 +583,7 @@ minetest.register_chatcommand("clearmobs",{
if num then range = num end if num then range = num end
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 for _,o in pairs(minetest.luaentities) do
if o and o.is_mob then if o and o.is_mob then