diff options
author | DS <vorunbekannt75@web.de> | 2017-04-09 07:19:40 +0200 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-04-09 01:19:40 -0400 |
commit | c9c4b4cd150dade811793c0795e7f6c875a5dd59 (patch) | |
tree | 936c461fa359c4a54f89006b09224fc8599c3d42 | |
parent | c2a288303f64707a64f38ff92fdb28b086aad749 (diff) | |
download | pipeworks-c9c4b4cd150dade811793c0795e7f6c875a5dd59.tar pipeworks-c9c4b4cd150dade811793c0795e7f6c875a5dd59.tar.gz pipeworks-c9c4b4cd150dade811793c0795e7f6c875a5dd59.tar.bz2 pipeworks-c9c4b4cd150dade811793c0795e7f6c875a5dd59.tar.xz pipeworks-c9c4b4cd150dade811793c0795e7f6c875a5dd59.zip |
make item drop by tubes nicer (#168)
* make item drop by tubes nicer
-rw-r--r-- | item_transport.lua | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/item_transport.lua b/item_transport.lua index bbdf003..43adeea 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -231,15 +231,13 @@ luaentity.register_entity("pipeworks:tubed_item", { end, on_step = function(self, dtime) + local pos = self:getpos() if self.start_pos == nil then - local pos = self:getpos() self.start_pos = vector.round(pos) self:setpos(pos) end - local pos = self:getpos() local stack = ItemStack(self.itemstring) - local drop_pos 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 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 - if drop_pos then - -- Using add_item instead of item_drop since this makes pipeworks backward - -- compatible with Minetest 0.4.13. - -- Using item_drop here makes Minetest 0.4.13 crash. - minetest.add_item(drop_pos, stack) - self:remove() - return - end + if pipeworks.drop_on_routing_fail or not tube_present or + minetest.get_item_group(rev_node.name,"tube") ~= 1 then + -- Using add_item instead of item_drop since this makes pipeworks backward + -- compatible with Minetest 0.4.13. + -- Using item_drop here makes Minetest 0.4.13 crash. + local dropped_item = minetest.add_item(self.start_pos, stack) + dropped_item:setvelocity(vector.multiply(velocity, 5)) + self:remove() + return else - if minetest.get_item_group(rev_node.name,"tube") == 1 then - velocity = vector.multiply(velocity, -1) - self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1))) - self:setvelocity(velocity) - else - if drop_pos then - minetest.add_item(drop_pos, stack) - self:remove() - return - end - end + velocity = vector.multiply(velocity, -1) + self:setpos(vector.subtract(self.start_pos, vector.multiply(vel, moved_by - 1))) + self:setvelocity(velocity) end end |