Fix the visual junction connection bug, remove EOL blanks

master
Joachim Stolberg 2022-01-05 21:23:57 +01:00
parent b21bc24522
commit 494976eb4b
12 changed files with 129 additions and 101 deletions

View File

@ -107,10 +107,13 @@ function networks.junction_type(pos, network, default_side, param2)
if connected(network, pos, dir) then
val = setbit(val, bit(dir2))
elseif network:is_secondary_node(pos, dir) then
local node = network:get_secondary_node(pos, dir)
if network:is_valid_dir(node, networks.Flip[dir]) then
val = setbit(val, bit(dir2))
end
end
end
end
return val
end

View File

@ -73,6 +73,16 @@ local function print_power_network_data(pos, api, netw, netw_type)
end
end
local function print_liquid_network_data(pos, api, netw_type, outdir)
local tlib2 = networks.registered_networks[api][netw_type]
local netw = networks.get_network_table(pos, tlib2, outdir)
if netw then
print(" - Number of network nodes: " .. (netw.num_nodes or 0))
print(" - Number of pumps: " .. #(netw.pump or {}))
print(" - Number of tanks: " .. #(netw.tank or {}))
end
end
local function print_netID(pos, api, netw_type)
local tlib2 = networks.registered_networks[api][netw_type]
for _,outdir in ipairs(networks.get_outdirs(pos, tlib2)) do
@ -80,6 +90,9 @@ local function print_netID(pos, api, netw_type)
local s = tubelib2.dir_to_string(outdir)
if netID then
print("- " .. s .. ": netwNum for '" .. netw_type .. "': " .. networks.netw_num(netID))
if api == "liquid" then
print_liquid_network_data(pos, api, netw_type, outdir)
end
else
print("- " .. s .. ": Node has no '" .. netw_type .. "' netID!!!")
end
@ -105,6 +118,19 @@ local function print_valid_sides(name, api, netw_type)
end
end
local function print_connected_nodes(pos, api, netw_type)
local tlib2 = networks.registered_networks[api][netw_type]
for outdir = 1,6 do
local destpos, indir = tlib2:get_connected_node_pos(pos, outdir)
if destpos and tlib2:connected(destpos) then
local s1 = tubelib2.dir_to_string(outdir)
local s2 = tubelib2.dir_to_string(indir)
local node = minetest.get_node(destpos)
print("- " .. s1 .. ": Node connected to " .. node.name .. " at " .. P2S(destpos) .. " from " .. s2)
end
end
end
-- debug print of node related data
local function debug_print(pos)
local node = minetest.get_node(pos)
@ -126,12 +152,11 @@ local function debug_print(pos)
print_sides(pos, api, netw_type)
if api == "power" then
print_power_network_data(pos, api, ndef.networks, netw_type)
elseif api == "liquid" then
--print_liquid_network_data(pos, api, netw_type)
end
print_netID(pos, api, netw_type)
print_secondary_node(pos, api, netw_type)
print_valid_sides(node.name, api, netw_type)
print_connected_nodes(pos, api, netw_type)
end
end