v0.4 - on_update function for secondary nodes introduced

This commit is contained in:
Joachim Stolberg 2018-11-11 10:32:54 +01:00
parent e04f493667
commit 96d43cc69e
4 changed files with 36 additions and 22 deletions

@ -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

@ -18,6 +18,19 @@ View to the north
V
5
+-------+
/ /| +-------+
/ / | / /|
/ / + / / |
/ / / +-------+ |
+-------+ / | | |
| | / | |/ |
| |/ +-------+| +
+-------+ | |/
+------+
+------+
| |
+------+ +---+------+---+ +------+

@ -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

@ -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