diff --git a/mods/fl_wildlife/api.lua b/mods/fl_wildlife/api.lua index c52c498..4b9411c 100644 --- a/mods/fl_wildlife/api.lua +++ b/mods/fl_wildlife/api.lua @@ -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"),}) diff --git a/mods/fl_wildlife/commands.lua b/mods/fl_wildlife/commands.lua new file mode 100644 index 0000000..b263f74 --- /dev/null +++ b/mods/fl_wildlife/commands.lua @@ -0,0 +1,21 @@ +minetest.register_chatcommand("clearents", { + description = "remove sepcified ents", + params = "", + 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 +}) diff --git a/mods/fl_wildlife/init.lua b/mods/fl_wildlife/init.lua index 9441beb..124a116 100644 --- a/mods/fl_wildlife/init.lua +++ b/mods/fl_wildlife/init.lua @@ -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",