mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-30 23:03:45 +01:00
Comment out logging, and add in the destruction
This commit is contained in:
parent
37ca0efe05
commit
c97fef03b9
@ -543,10 +543,7 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
if not param or param == "" then
|
if not param or param == "" then
|
||||||
minetest.log("Incorrect usage. For more information please type: /help clearmobs")
|
minetest.log("Incorrect usage. For more information please type: /help clearmobs")
|
||||||
return
|
return
|
||||||
else
|
|
||||||
minetest.log("param: " .. dump(param))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local mob, unsafe = param:match("^([%w]+)[ ]?([%w%d]*)$")
|
local mob, unsafe = param:match("^([%w]+)[ ]?([%w%d]*)$")
|
||||||
|
|
||||||
local all = false
|
local all = false
|
||||||
@ -554,6 +551,7 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
|
|
||||||
local mob_name, mob_type, range
|
local mob_name, mob_type, range
|
||||||
|
|
||||||
|
-- Param 1 resolve
|
||||||
if mob and mob ~= "" then
|
if mob and mob ~= "" then
|
||||||
if mob == "all" then
|
if mob == "all" then
|
||||||
all = true
|
all = true
|
||||||
@ -562,12 +560,13 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
elseif mob then
|
elseif mob then
|
||||||
mob_name = mob
|
mob_name = mob
|
||||||
end
|
end
|
||||||
minetest.log ("mob: [" .. mob .. "]")
|
--minetest.log ("mob: [" .. mob .. "]")
|
||||||
else
|
else
|
||||||
minetest.log("No valid second param")
|
--minetest.log("No valid second param")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Param 2 resolve
|
||||||
if unsafe and unsafe ~= "" then
|
if unsafe and unsafe ~= "" then
|
||||||
minetest.log ("unsafe: [" .. unsafe .. "]")
|
minetest.log ("unsafe: [" .. unsafe .. "]")
|
||||||
if unsafe == "nametagged" then
|
if unsafe == "nametagged" then
|
||||||
@ -575,37 +574,30 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
end
|
end
|
||||||
|
|
||||||
local num = tonumber(unsafe)
|
local num = tonumber(unsafe)
|
||||||
if num then
|
if num then range = num end
|
||||||
minetest.log("valid number")
|
|
||||||
range = num
|
|
||||||
else
|
|
||||||
minetest.log("not a number")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = minetest.get_player_by_name(n)
|
local p = minetest.get_player_by_name(n)
|
||||||
|
|
||||||
minetest.log("Range: ".. tostring(range))
|
|
||||||
|
|
||||||
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
|
||||||
local mob_match = false
|
local mob_match = false
|
||||||
|
|
||||||
if all then
|
if all then
|
||||||
minetest.log("Match - All mobs specified")
|
--minetest.log("Match - All mobs specified")
|
||||||
mob_match = true
|
mob_match = true
|
||||||
elseif mob_type then
|
elseif mob_type then
|
||||||
|
|
||||||
minetest.log("Match - o.type: ".. tostring(o.type))
|
--minetest.log("Match - o.type: ".. tostring(o.type))
|
||||||
minetest.log("mob_type: ".. tostring(mob_type))
|
--minetest.log("mob_type: ".. tostring(mob_type))
|
||||||
if mob_type == "monster" and o.type == mob_type then
|
if mob_type == "monster" and o.type == mob_type then
|
||||||
minetest.log("Match - monster")
|
--minetest.log("Match - monster")
|
||||||
mob_match = true
|
mob_match = true
|
||||||
elseif mob_type == "passive" and o.type ~= "monster" and o.type ~= "npc" then
|
elseif mob_type == "passive" and o.type ~= "monster" and o.type ~= "npc" then
|
||||||
minetest.log("Match - passive")
|
--minetest.log("Match - passive")
|
||||||
mob_match = true
|
mob_match = true
|
||||||
else
|
else
|
||||||
minetest.log("No match for type.")
|
--minetest.log("No match for type.")
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif mob_name and (o.name == mob_name or string.find(o.name, mob_name)) then
|
elseif mob_name and (o.name == mob_name or string.find(o.name, mob_name)) then
|
||||||
@ -625,20 +617,20 @@ minetest.register_chatcommand("clearmobs",{
|
|||||||
if ( vector.distance(p:get_pos(),o.object:get_pos()) <= range ) then
|
if ( vector.distance(p:get_pos(),o.object:get_pos()) <= range ) then
|
||||||
in_range = true
|
in_range = true
|
||||||
else
|
else
|
||||||
minetest.log("Out of range")
|
--minetest.log("Out of range")
|
||||||
in_range = false
|
in_range = false
|
||||||
end
|
end
|
||||||
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 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
|
elseif nametagged and o.nametag then
|
||||||
minetest.log("Namedtagged and it has a name tag. Kill it")
|
--minetest.log("Namedtagged and it has a name tag. Kill it")
|
||||||
--o.object:remove()
|
o.object:remove()
|
||||||
else
|
else
|
||||||
minetest.log("Tamed or out of range, do not kill")
|
--minetest.log("Tamed or out of range, do not kill")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user