mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-29 23:43:42 +01:00
Restore moved armor stand objects to original position when possible
This commit is contained in:
parent
170ee39aed
commit
72cffbae17
@ -203,22 +203,25 @@ minetest.register_entity("3d_armor_stand:armor_entity", {
|
|||||||
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,
|
timer = 0,
|
||||||
|
pos = nil,
|
||||||
on_activate = function(self)
|
on_activate = function(self)
|
||||||
local pos = self.object:getpos()
|
self.pos = self.object:getpos()
|
||||||
update_entity(pos)
|
update_entity(self.pos)
|
||||||
end,
|
end,
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
if self.timer > 4 then
|
if self.timer > 4 then
|
||||||
local pos = self.object:getpos()
|
self.timer = 0
|
||||||
if pos then
|
if self.pos then
|
||||||
local node = minetest.get_node(vector.round(pos))
|
self.object:setpos(self.pos)
|
||||||
if not string.find(node.name, "3d_armor_stand:") then
|
self.object:setvelocity({x=0, y=0, z=0})
|
||||||
|
local node = minetest.get_node(self.pos)
|
||||||
|
if string.find(node.name, "3d_armor_stand:") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
timer = 0
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user