Allow reversing direction if there's nowhere to go

This commit is contained in:
Carter Kolwey 2017-02-28 22:15:18 -06:00 committed by Diego Martínez
parent f7fe95231d
commit cdbe93cdd8
2 changed files with 18 additions and 8 deletions

View File

@ -19,5 +19,6 @@ pipeworks.enable_mese_sand_tube = true
pipeworks.enable_one_way_tube = true pipeworks.enable_one_way_tube = true
pipeworks.enable_priority_tube = true pipeworks.enable_priority_tube = true
pipeworks.enable_cyclic_mode = true pipeworks.enable_cyclic_mode = true
pipeworks.drop_on_routing_fail = false
pipeworks.delete_item_on_clearobject = true pipeworks.delete_item_on_clearobject = true

View File

@ -246,15 +246,24 @@ luaentity.register_entity("pipeworks:tubed_item", {
if moved then if moved then
local found_next, new_velocity = go_next(self.start_pos, velocity, stack) -- todo: color local found_next, new_velocity = go_next(self.start_pos, velocity, stack) -- todo: color
local rev_vel = vector.multiply(velocity, -1)
local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
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 if not found_next then
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 drop_pos then drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
-- Using add_item instead of item_drop since this makes pipeworks backward if drop_pos then
-- compatible with Minetest 0.4.13. -- Using add_item instead of item_drop since this makes pipeworks backward
-- Using item_drop here makes Minetest 0.4.13 crash. -- compatible with Minetest 0.4.13.
minetest.add_item(drop_pos, stack) -- Using item_drop here makes Minetest 0.4.13 crash.
self:remove() minetest.add_item(drop_pos, stack)
return self:remove()
return
end
else
velocity = vector.multiply(velocity, -1)
self:setvelocity(velocity)
end end
end end