Merge pull request #36 from Novatux/tubesfix

Fix crash sometimes with tubes
This commit is contained in:
VanessaE 2013-06-05 07:38:39 -07:00
commit 3796ddd3d8

View File

@ -197,6 +197,10 @@ function tube_item(pos, item)
return obj return obj
end end
local function roundpos(pos)
return {x=math.floor(pos.x+0.5),y=math.floor(pos.y+0.5),z=math.floor(pos.z+0.5)}
end
minetest.register_entity("pipeworks:tubed_item", { minetest.register_entity("pipeworks:tubed_item", {
initial_properties = { initial_properties = {
hp_max = 1, hp_max = 1,
@ -278,7 +282,10 @@ minetest.register_entity("pipeworks:tubed_item", {
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
if self.start_pos then if self.start_pos==nil then
local pos = self.object:getpos()
self.start_pos=roundpos(pos)
end
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.env:get_node(pos) local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
@ -357,11 +364,10 @@ minetest.register_entity("pipeworks:tubed_item", {
end end
end end
end
}) })
function addVect(pos,vect) local function addVect(pos,vect)
return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z} return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
end end