clearents command and egg protection

This commit is contained in:
unknown 2021-10-16 21:09:57 -04:00
parent 89d1fdad21
commit 4e5034a3cd
3 changed files with 27 additions and 1 deletions

View File

@ -24,7 +24,11 @@ function fl_wildlife.egg_it(t_name, d_name, color)
inventory_image = "farlands_egg.png^(farlands_egg_overlay.png^[colorize:" .. color .. ")", --"404.png",
stack_max = 99,
on_place = function(itemstack, placer, pointed_thing)
local ent = minetest.add_entity(pointed_thing.above, t_name)
if pointed_thing.type ~= "node" then return itemstack end
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then return itemstack end
local pos = pointed_thing.under
pos.y = pos.y+1
local ent = minetest.add_entity(pos, t_name)
if itemstack:get_meta():get_string("description") ~= "" then
local self = ent:get_luaentity()
self.object:set_properties({nametag = itemstack:get_meta():get_string("description"),})

View File

@ -0,0 +1,21 @@
minetest.register_chatcommand("clearents", {
description = "remove sepcified ents",
params = "<ent_name><radius>",
privs = {server = true},
func = function(name, param)
local counter = 0
local player = minetest.get_player_by_name(name)
local split = param:split(" ")
local radius = 32
if split[2] then radius = tonumber(split[2]) end
if not minetest.registered_entities[split[1]] then return false, "not valid ent" end
local objects = minetest.get_objects_inside_radius(player:get_pos(), radius)
for _, obj in pairs(objects) do
local ent = obj:get_luaentity()
if ent and ent.name == split[1] then obj:remove() counter = counter+1 end
end
return true, "[fl_wildlife]: " .. counter .. " ents removed"
end
})

View File

@ -15,6 +15,7 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath .. "/api.lua")
dofile(modpath .. "/node_items.lua")
dofile(modpath .. "/crafts.lua")
dofile(modpath .. "/commands.lua")
local mob_brains = {
"villager_brain",