From 5d2e9c49c22dcbefb488dd8cf3bee7291e073638 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Wed, 1 May 2019 12:00:34 +0200 Subject: [PATCH] new API function for Hopper like nodes added --- tube_api.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tube_api.lua b/tube_api.lua index fe6aa75..d94d4d1 100644 --- a/tube_api.lua +++ b/tube_api.lua @@ -13,7 +13,7 @@ ]]-- -- Version for compatibility checks, see readme.md/history -tubelib2.version = 1.2 +tubelib2.version = 1.3 -- for lazy programmers local S = function(pos) if pos then return minetest.pos_to_string(pos) end end @@ -249,6 +249,17 @@ function Tube:get_connected_node_pos(pos, dir) return spos, fdir end +-- Check if node at given position is a tubelib2 compatible node, +-- able to receive and/or deliver items. +-- If dir == nil then node_pos = pos +-- Function returns the result (true/false), new pos, and the node +function Tube:compatible_node(pos, dir) + local npos = vector.add(pos, Dir6dToVector[dir or 0]) + local node = self:get_node_lvm(npos) + return self.secondary_node_names[node.name], npos, node +end + + -- To be called from a repair tool in the case of a "WorldEdit" or with -- legacy nodes corrupted tube line. function Tube:tool_repair_tube(pos) @@ -349,4 +360,4 @@ end -- Used to change the tube nodes texture (e.g. on/off state) function Tube:switch_tube_line(pos, dir, state) self:switch_nodes(pos, dir, state) -end \ No newline at end of file +end