From e5de4bba65e0607c727a920982f1d23d3d1ca766 Mon Sep 17 00:00:00 2001 From: cora Date: Sun, 17 Apr 2022 12:10:10 +0200 Subject: [PATCH] keep nametagged mobs, add "all" argument --- mods/ENTITIES/mcl_mobs/api.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 914a919a1..0429c5ea5 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -104,10 +104,15 @@ local mod_experience = minetest.get_modpath("mcl_experience") ~= nil --Helper function to clear all mobs because /clearobjects removes too much minetest.register_chatcommand("clearmobs",{ privs={maphack=true}, - description=S("Removes all spawned mobs"), - func=function() + params = "", + description=S("Removes all spawned mobs except nametagged ones. Supply the optional all argument to remove all mobs"), + func=function(n,p) for k,o in pairs(minetest.luaentities) do - if o.type == "ambient" or o.type == "animal" or o.type == "monster" or o.type == "npc" then o.object:remove() end + if o.type == "ambient" or o.type == "animal" or o.type == "monster" or o.type == "npc" then + if p == "all" or not o.nametag then + o.object:remove() + end + end end end})