forked from mtcontrib/3d_armor
Auto remove stray armor stand entities
This commit is contained in:
parent
59bbc55b73
commit
170ee39aed
@ -38,7 +38,7 @@ local function update_entity(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if object then
|
if object then
|
||||||
if node.name ~= "3d_armor_stand:armor_stand" and node.name ~= "3d_armor_stand:locked_armor_stand" then
|
if not string.find(node.name, "3d_armor_stand:") then
|
||||||
object:remove()
|
object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -153,7 +153,9 @@ local function has_locked_armor_stand_privilege(meta, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local node = {}
|
local node = {}
|
||||||
for k,v in pairs(minetest.registered_nodes["3d_armor_stand:armor_stand"]) do node[k] = v end
|
for k,v in pairs(minetest.registered_nodes["3d_armor_stand:armor_stand"]) do
|
||||||
|
node[k] = v
|
||||||
|
end
|
||||||
node.description = "Locked " .. node.description
|
node.description = "Locked " .. node.description
|
||||||
node.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
node.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -200,10 +202,24 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
|
|||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1},
|
collisionbox = {-0.1,-0.4,-0.1, 0.1,1.3,0.1},
|
||||||
textures = {"3d_armor_trans.png"},
|
textures = {"3d_armor_trans.png"},
|
||||||
|
timer = 0,
|
||||||
on_activate = function(self)
|
on_activate = function(self)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
update_entity(pos)
|
update_entity(pos)
|
||||||
end,
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
self.timer = self.timer + dtime
|
||||||
|
if self.timer > 4 then
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
if pos then
|
||||||
|
local node = minetest.get_node(vector.round(pos))
|
||||||
|
if not string.find(node.name, "3d_armor_stand:") then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
timer = 0
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -221,3 +237,4 @@ minetest.register_craft({
|
|||||||
{"3d_armor_stand:armor_stand", "default:steel_ingot"},
|
{"3d_armor_stand:armor_stand", "default:steel_ingot"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user