summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-29 16:54:38 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-29 16:54:38 -0400
commit3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4 (patch)
tree8c12a73b7ca066639bcb3ec7ed251679300875ed
parent0e8a82fdba147bd6507f10226883dfa1936ab3ec (diff)
downloadpipeworks-3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4.tar
pipeworks-3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4.tar.gz
pipeworks-3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4.tar.bz2
pipeworks-3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4.tar.xz
pipeworks-3a77d1dd8e8929ff07fd1bdaf0a180c03ee128e4.zip
if an item should reverse dir (e.g. full destination),
and it's not going back into a tube, reject it and pop out as an item
-rw-r--r--item_transport.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/item_transport.lua b/item_transport.lua
index c89eaf5..e906387 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -251,8 +251,8 @@ luaentity.register_entity("pipeworks:tubed_item", {
local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
if not found_next then
+ local drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
if pipeworks.drop_on_routing_fail or not tube_present then
- drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
if drop_pos then
-- Using add_item instead of item_drop since this makes pipeworks backward
-- compatible with Minetest 0.4.13.
@@ -262,9 +262,17 @@ luaentity.register_entity("pipeworks:tubed_item", {
return
end
else
- print("[Pipeworks] Warning - tubed item had to reverse direction at "..minetest.pos_to_string(self.start_pos))
- velocity = vector.multiply(velocity, -1)
- self:setvelocity(velocity)
+ if minetest.get_item_group(rev_node.name,"tube") == 1 then
+ print("[Pipeworks] Warning - tubed item had to reverse direction at "..minetest.pos_to_string(self.start_pos))
+ velocity = vector.multiply(velocity, -1)
+ self:setvelocity(velocity)
+ else
+ if drop_pos then
+ minetest.add_item(drop_pos, stack)
+ self:remove()
+ return
+ end
+ end
end
end