fix pipe and ta4 cable junction issues

This commit is contained in:
Joachim Stolberg 2021-05-12 21:48:17 +02:00
parent 27cf14bafe
commit 555166d58e
3 changed files with 20 additions and 21 deletions

View File

@ -25,7 +25,7 @@ local Pipe = tubelib2.Tube:new({
dirs_to_check = {1,2,3,4,5,6}, dirs_to_check = {1,2,3,4,5,6},
max_tube_length = MAX_PIPE_LENGHT, max_tube_length = MAX_PIPE_LENGHT,
show_infotext = false, show_infotext = false,
force_to_use_tubes = true, force_to_use_tubes = false,
tube_type = "pipe2", tube_type = "pipe2",
primary_node_names = { primary_node_names = {
"techage:ta3_pipeS", "techage:ta3_pipeA", "techage:ta3_pipeS", "techage:ta3_pipeA",

View File

@ -112,9 +112,9 @@ end
-- remote inventory. -- remote inventory.
function liquid.peek(pos, outdir) function liquid.peek(pos, outdir)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos) local liq = LQD(item.pos)
if liquid and liquid.peek then if liq and liq.peek then
return liquid.peek(item.pos, item.indir) return liq.peek(item.pos, item.indir)
end end
end end
end end
@ -123,16 +123,16 @@ end
-- return leftover amount -- return leftover amount
function liquid.put(pos, outdir, name, amount, player_name) function liquid.put(pos, outdir, name, amount, player_name)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos) local liq = LQD(item.pos)
if liquid and liquid.put and liquid.peek then if liq and liq.put and liq.peek then
-- wrong items? -- wrong items?
local peek = liquid.peek(item.pos, item.indir) local peek = liq.peek(item.pos, item.indir)
if peek and peek ~= name then return amount or 0 end if peek and peek ~= name then return amount or 0 end
if player_name then if player_name then
local num = techage.get_node_number(pos) or "000" local num = techage.get_node_number(pos) or "000"
techage.mark_position(player_name, item.pos, "("..num..") put", "", 1) techage.mark_position(player_name, item.pos, "("..num..") put", "", 1)
end end
amount = liquid.put(item.pos, item.indir, name, amount) amount = liq.put(item.pos, item.indir, name, amount)
if not amount or amount == 0 then break end if not amount or amount == 0 then break end
end end
end end
@ -143,30 +143,27 @@ end
-- return taken amount and item name -- return taken amount and item name
function liquid.take(pos, outdir, name, amount, player_name) function liquid.take(pos, outdir, name, amount, player_name)
local taken = 0 local taken = 0
local item_name = nil
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos) local liq = LQD(item.pos)
if liquid and liquid.take then if liq and liq.take then
if player_name then if player_name then
local num = techage.get_node_number(pos) local num = techage.get_node_number(pos)
techage.mark_position(player_name, item.pos, "("..num..") take", "", 1) techage.mark_position(player_name, item.pos, "("..num..") take", "", 1)
end end
local val, name = liquid.take(item.pos, item.indir, name, amount - taken) taken, name = liq.take(item.pos, item.indir, name, amount)
if val and name then if taken and name and taken > 0 then
taken = taken + val break
item_name = name
if amount - taken == 0 then break end
end end
end end
end end
return taken, item_name return taken, name
end end
function liquid.untake(pos, outdir, name, amount) function liquid.untake(pos, outdir, name, amount)
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
local liquid = LQD(item.pos) local liq = LQD(item.pos)
if liquid and liquid.untake then if liq and liq.untake then
amount = liquid.untake(item.pos, item.indir, name, amount) amount = liq.untake(item.pos, item.indir, name, amount)
if not amount or amount == 0 then break end if not amount or amount == 0 then break end
end end
end end

View File

@ -141,7 +141,9 @@ minetest.register_node("techage:ta4_power_box", {
connect_back = {{-1/16, -1/16, 0, 1/16, 1/16, 1/2}}, connect_back = {{-1/16, -1/16, 0, 1/16, 1/16, 1/2}},
connect_front = {{-1/16, -1/16, -1/2, 1/16, 1/16, 0}}, connect_front = {{-1/16, -1/16, -1/2, 1/16, 1/16, 0}},
}, },
connects_to = {"techage:ta4_power_cableA", "techage:ta4_power_cableS", "techage:ta4_solar_inverter"}, connects_to = {"techage:ta4_power_cableA", "techage:ta4_power_cableS",
"techage:ta4_solar_inverter", "techage:ta4_solar_carrier",
"techage:ta4_solar_carrierB"},
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
Cable:after_place_node(pos) Cable:after_place_node(pos)