mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-01-11 18:40:37 +01:00
parent
c2a288303f
commit
c9c4b4cd15
@ -231,15 +231,13 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
|
local pos = self:getpos()
|
||||||
if self.start_pos == nil then
|
if self.start_pos == nil then
|
||||||
local pos = self:getpos()
|
|
||||||
self.start_pos = vector.round(pos)
|
self.start_pos = vector.round(pos)
|
||||||
self:setpos(pos)
|
self:setpos(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self:getpos()
|
|
||||||
local stack = ItemStack(self.itemstring)
|
local stack = ItemStack(self.itemstring)
|
||||||
local drop_pos
|
|
||||||
|
|
||||||
local velocity = self:getvelocity()
|
local velocity = self:getvelocity()
|
||||||
|
|
||||||
@ -284,28 +282,19 @@ 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 or
|
||||||
if pipeworks.drop_on_routing_fail or not tube_present then
|
minetest.get_item_group(rev_node.name,"tube") ~= 1 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.
|
-- Using item_drop here makes Minetest 0.4.13 crash.
|
||||||
-- Using item_drop here makes Minetest 0.4.13 crash.
|
local dropped_item = minetest.add_item(self.start_pos, stack)
|
||||||
minetest.add_item(drop_pos, stack)
|
dropped_item:setvelocity(vector.multiply(velocity, 5))
|
||||||
self:remove()
|
self:remove()
|
||||||
return
|
return
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if minetest.get_item_group(rev_node.name,"tube") == 1 then
|
velocity = vector.multiply(velocity, -1)
|
||||||
velocity = vector.multiply(velocity, -1)
|
self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1)))
|
||||||
self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user