1
0
Fork 0

keep nametagged mobs, add "all" argument

This commit is contained in:
cora 2022-04-17 12:10:10 +02:00 committed by Gitea
parent 628686ce79
commit e5de4bba65
1 changed files with 8 additions and 3 deletions

View File

@ -104,10 +104,15 @@ local mod_experience = minetest.get_modpath("mcl_experience") ~= nil
--Helper function to clear all mobs because /clearobjects removes too much --Helper function to clear all mobs because /clearobjects removes too much
minetest.register_chatcommand("clearmobs",{ minetest.register_chatcommand("clearmobs",{
privs={maphack=true}, privs={maphack=true},
description=S("Removes all spawned mobs"), params = "<all>",
func=function() 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 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
end}) end})