summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessaE <vanessaezekowitz@gmail.com>2013-06-05 07:38:39 -0700
committerVanessaE <vanessaezekowitz@gmail.com>2013-06-05 07:38:39 -0700
commit3796ddd3d8916ed47996846b2b30ad0ae460f9cc (patch)
treeffa070946a096391efbe733e487d0e0575b763f9
parent698c84666cacae42158b23c6b93e8a9d3113a497 (diff)
parent14adc2fd9bf51085172d32e952e96afcc61d7a16 (diff)
downloadpipeworks-3796ddd3d8916ed47996846b2b30ad0ae460f9cc.tar
pipeworks-3796ddd3d8916ed47996846b2b30ad0ae460f9cc.tar.gz
pipeworks-3796ddd3d8916ed47996846b2b30ad0ae460f9cc.tar.bz2
pipeworks-3796ddd3d8916ed47996846b2b30ad0ae460f9cc.tar.xz
pipeworks-3796ddd3d8916ed47996846b2b30ad0ae460f9cc.zip
Merge pull request #36 from Novatux/tubesfix
Fix crash sometimes with tubes
-rw-r--r--item_transport.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/item_transport.lua b/item_transport.lua
index 3a9943b..bb6f91b 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -197,6 +197,10 @@ function tube_item(pos, item)
return obj
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", {
initial_properties = {
hp_max = 1,
@@ -278,7 +282,10 @@ minetest.register_entity("pipeworks:tubed_item", {
end,
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 node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
@@ -356,13 +363,12 @@ minetest.register_entity("pipeworks:tubed_item", {
self.object:setvelocity(velocity)
end
- end
end
})
-function addVect(pos,vect)
-return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
+local function addVect(pos,vect)
+ return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
end
adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}