Merge pull request 'clearmobs command improvement' (#3543) from clearmobs into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3543 Reviewed-by: ancientmarinerdev <ancientmariner_dev@proton.me>
This commit is contained in:
commit
583d066587
@ -535,11 +535,11 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("clearmobs",{
|
minetest.register_chatcommand("clearmobs", {
|
||||||
privs={maphack=true},
|
privs = { maphack = true },
|
||||||
params = "[<all>|<hostile/passive>|<name>] [<nametagged>|<range>]",
|
params = "[all|monster|passive|<mob name> [<range>|nametagged|tamed]]",
|
||||||
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 mobs except nametagged and tamed ones. For the second parameter, use nametagged/tamed to select only nametagged/tamed mobs, or a range to specify a maximum distance from the player."),
|
||||||
func=function(player, param)
|
func = function(player, param)
|
||||||
local default = false
|
local default = false
|
||||||
if not param or param == "" then
|
if not param or param == "" then
|
||||||
default = true
|
default = true
|
||||||
@ -550,6 +550,7 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
|
|
||||||
local all = false
|
local all = false
|
||||||
local nametagged = false
|
local nametagged = false
|
||||||
|
local tamed = false
|
||||||
|
|
||||||
local mob_name, mob_type, range
|
local mob_name, mob_type, range
|
||||||
|
|
||||||
@ -577,6 +578,8 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
--minetest.log ("unsafe: [" .. unsafe .. "]")
|
--minetest.log ("unsafe: [" .. unsafe .. "]")
|
||||||
if unsafe == "nametagged" then
|
if unsafe == "nametagged" then
|
||||||
nametagged = true
|
nametagged = true
|
||||||
|
elseif unsafe == "tamed" then
|
||||||
|
tamed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local num = tonumber(unsafe)
|
local num = tonumber(unsafe)
|
||||||
@ -629,14 +632,20 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
end
|
end
|
||||||
|
|
||||||
--minetest.log("o.nametag: ".. tostring(o.nametag))
|
--minetest.log("o.nametag: ".. tostring(o.nametag))
|
||||||
if in_range and ( (not o.nametag or o.nametag == "" ) and not o.tamed ) then
|
|
||||||
|
if nametagged then
|
||||||
|
if o.nametag then
|
||||||
|
--minetest.log("Namedtagged and it has a name tag. Kill it")
|
||||||
|
o.object:remove()
|
||||||
|
end
|
||||||
|
elseif tamed then
|
||||||
|
if o.tamed then
|
||||||
|
--minetest.log("Tamed. Kill it")
|
||||||
|
o.object:remove()
|
||||||
|
end
|
||||||
|
elseif in_range and (not o.nametag or o.nametag == "") and not o.tamed then
|
||||||
--minetest.log("No nametag or tamed. Kill it")
|
--minetest.log("No nametag or tamed. Kill it")
|
||||||
o.object:remove()
|
o.object:remove()
|
||||||
elseif nametagged and o.nametag then
|
|
||||||
--minetest.log("Namedtagged and it has a name tag. Kill it")
|
|
||||||
o.object:remove()
|
|
||||||
else
|
|
||||||
--minetest.log("Tamed or out of range, do not kill")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,3 +9,5 @@ Before you use the name tag, you need to set a name at an anvil. Then you can us
|
|||||||
Only peaceful mobs allowed!=
|
Only peaceful mobs allowed!=
|
||||||
Give names to mobs=
|
Give names to mobs=
|
||||||
Set name at anvil=
|
Set name at anvil=
|
||||||
|
Removes specified mobs except nametagged and tamed ones. For the second parameter, use nametagged/tamed to select only nametagged/tamed mobs, or a range to specify a maximum distance from the player.=
|
||||||
|
Default usage. Clearing hostile mobs. For more options please type: /help clearmobs=
|
||||||
|
Loading…
Reference in New Issue
Block a user