diff options
author | Novatux <nathanael.courant@laposte.net> | 2014-01-03 13:29:38 +0100 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2014-01-03 13:29:38 +0100 |
commit | e3a27452e7641d41a3b5ac92d79fc9cefb877224 (patch) | |
tree | 465069370c9238d287191d360fe067528960b595 /item_transport.lua | |
parent | ddfc8173ac89e03b38ced53f095acf7fcb7e3249 (diff) |
Support for the mesecons mvps callbackorigin/mvps
Diffstat (limited to 'item_transport.lua')
-rw-r--r-- | item_transport.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/item_transport.lua b/item_transport.lua index a3774ae..af5a817 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -467,3 +467,26 @@ minetest.register_entity("pipeworks:tubed_item", { end }) +if minetest.get_modpath("mesecons_mvps") ~= nil then + mesecon:register_mvps_unmov("pipeworks:tubed_item") + mesecon:register_on_mvps_move(function(moved_nodes) + local objects_to_move = {} + for _, n in ipairs(moved_nodes) do + local objects = minetest.get_objects_inside_radius(n.oldpos, 1) + for _, obj in ipairs(objects) do + local entity = obj:get_luaentity() + if entity and entity.name == "pipeworks:tubed_item" then + objects_to_move[#objects_to_move+1] = obj + end + end + end + if #objects_to_move > 0 then + local dir = vector.subtract(moved_nodes[1].pos, moved_nodes[1].oldpos) + for _, obj in ipairs(objects_to_move) do + local entity = obj:get_luaentity() + obj:setpos(vector.add(obj:getpos(), dir)) + entity.start_pos = vector.add(entity.start_pos, dir) + end + end + end) +end |