From 96d43cc69e86feb622734f9bd2a4e1eb4871bc63 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 11 Nov 2018 10:32:54 +0100 Subject: [PATCH] v0.4 - on_update function for secondary nodes introduced --- README.md | 31 ++++++++++++++++--------------- design.txt | 13 +++++++++++++ internal1.lua | 2 +- tube_test.lua | 12 ++++++------ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 60b1c6f..79e5633 100644 --- a/README.md +++ b/README.md @@ -22,20 +22,20 @@ Tubelib2 specific 6D directions (1 = North, 2 = East, 3 = South, 4 = West, 5 = D All 6D dirs are the view from the node to the outer side Tubes are based on two node types, "angled" and "straight" tubes. - - - +-------+ - / /| +-------+ - +-------+ | / /| - | | | / / | - | | | +-------+ | - | | | | | | - | | | | |/ | - | | + +-------+| + - | |/ | |/ - +-------+ +------+ - - + + + +-------+ + / /| +-------+ + / / | / /| + / / + / / | + / / / +-------+ | + +-------+ / | | | + | | / | |/ | + | |/ +-------+| + + +-------+ | |/ + +------+ + + All other nodes are build by means of axis/rotation variants based on param2 (paramtype2 == "facedir"). @@ -53,7 +53,8 @@ default # License Copyright (C) 2017-2018 Joachim Stolberg -Code: Licensed under the GNU LGPL version 2.1 or later. See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt +Code: Licensed under the GNU LGPL version 2.1 or later. + See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt Textures: CC0 ## Dependencies diff --git a/design.txt b/design.txt index 025eff9..b707eb8 100644 --- a/design.txt +++ b/design.txt @@ -18,6 +18,19 @@ View to the north V 5 + + +-------+ + / /| +-------+ + / / | / /| + / / + / / | + / / / +-------+ | + +-------+ / | | | + | | / | |/ | + | |/ +-------+| + + +-------+ | |/ + +------+ + + +------+ | | +------+ +---+------+---+ +------+ diff --git a/internal1.lua b/internal1.lua index e59b332..907f769 100644 --- a/internal1.lua +++ b/internal1.lua @@ -153,7 +153,7 @@ function Tube:update_secondary_node(fpos,fdir, npos,ndir) local fpos2, node = self:get_node(fpos, fdir) if minetest.registered_nodes[node.name].tubelib2_on_update then local npos2 = self:get_pos(npos, ndir) - minetest.registered_nodes[node.name].tubelib2_on_update(fpos2, npos2, ndir) + minetest.registered_nodes[node.name].tubelib2_on_update(fpos2, Turn180Deg[fdir], npos2, ndir) end end diff --git a/tube_test.lua b/tube_test.lua index 82114df..514837f 100644 --- a/tube_test.lua +++ b/tube_test.lua @@ -32,11 +32,6 @@ local Tube = tubelib2.Tube:new({ "tubelib2:source", "tubelib2:junction", "tubelib2:teleporter"}, after_place_tube = function(pos, param2, tube_type, num_tubes, tbl) minetest.set_node(pos, {name = "tubelib2:tube"..tube_type, param2 = param2}) --- minetest.sound_play({ --- name="default_place_node_glass"},{ --- gain=1, --- max_hear_distance=5, --- loop=false}) end, }) @@ -187,7 +182,7 @@ minetest.register_node("tubelib2:junction", { Tube:after_dig_node(pos) end, - tubelib2_on_update = function(pos, peer_pos, peer_dir) + tubelib2_on_update = function(pos, out_dir, peer_pos, peer_in_dir) if Tube:secondary_node(peer_pos) then local sdir = tubelib2.dir_to_string(peer_dir) local node = minetest.get_node(peer_pos) @@ -288,6 +283,11 @@ local function remove_tube(itemstack, placer, pointed_thing) else Tube:tool_remove_tube(pos, "default_break_glass") end + else + minetest.chat_send_player(placer:get_player_name(), + "[Tool Help]\n".. + " left: remove node\n".. + " right: repair tube line\n") end end