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
This commit is contained in:
Vanessa Ezekowitz 2017-03-29 16:54:38 -04:00
parent 0e8a82fdba
commit 3a77d1dd8e

View File

@ -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 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 local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
if not found_next then 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 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 if drop_pos then
-- Using add_item instead of item_drop since this makes pipeworks backward -- Using add_item instead of item_drop since this makes pipeworks backward
-- compatible with Minetest 0.4.13. -- compatible with Minetest 0.4.13.
@ -262,9 +262,17 @@ luaentity.register_entity("pipeworks:tubed_item", {
return return
end end
else else
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)) print("[Pipeworks] Warning - tubed item had to reverse direction at "..minetest.pos_to_string(self.start_pos))
velocity = vector.multiply(velocity, -1) velocity = vector.multiply(velocity, -1)
self:setvelocity(velocity) self:setvelocity(velocity)
else
if drop_pos then
minetest.add_item(drop_pos, stack)
self:remove()
return
end
end
end end
end end