Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

power multiplication fix #655

Merged
merged 8 commits into from
Nov 29, 2024
3 changes: 1 addition & 2 deletions technic/machines/register/cables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ function technic.clear_networks(pos)

-- Actually add it to the (cached) network
-- !! IMPORTANT: ../switching_station.lua -> check_node_subp() must be kept in sync
technic.cables[minetest.hash_node_position(pos)] = network_id
pos.visited = 1
if technic.is_tier_cable(node.name, tier) then
-- Found a cable
technic.cables[minetest.hash_node_position(pos)] = network_id
table.insert(network.all_nodes,pos)
elseif technic.machines[tier][node.name] then
-- Found a machine
Expand Down
20 changes: 11 additions & 9 deletions technic/machines/switching_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ end
-- Add a wire node to the LV/MV/HV network
-- Returns: indicator whether the cable is new in the network
local hash_node_position = minetest.hash_node_position
local function add_network_node(nodes, pos, network_id)
local function add_network_node(nodes, pos, network_id, cable)
SmallJoker marked this conversation as resolved.
Show resolved Hide resolved
local node_id = hash_node_position(pos)
technic.cables[node_id] = network_id
if cable then
technic.cables[node_id] = network_id
end
if nodes[node_id] then
return false
end
Expand All @@ -111,7 +113,7 @@ local function add_network_node(nodes, pos, network_id)
end

local function add_cable_node(nodes, pos, network_id, queue)
if add_network_node(nodes, pos, network_id) then
if add_network_node(nodes, pos, network_id, true) then
queue[#queue + 1] = pos
end
end
Expand Down Expand Up @@ -149,18 +151,18 @@ local check_node_subp = function(network, pos, machines, sw_pos, from_below, net
end

if eu_type == technic.producer then
add_network_node(network.PR_nodes, pos, network_id)
add_network_node(network.PR_nodes, pos, network_id, false)
elseif eu_type == technic.receiver then
add_network_node(network.RE_nodes, pos, network_id)
add_network_node(network.RE_nodes, pos, network_id, false)
elseif eu_type == technic.producer_receiver then
add_network_node(network.PR_nodes, pos, network_id)
add_network_node(network.RE_nodes, pos, network_id)
add_network_node(network.PR_nodes, pos, network_id, false)
add_network_node(network.RE_nodes, pos, network_id, false)
elseif eu_type == technic.battery then
add_network_node(network.BA_nodes, pos, network_id)
add_network_node(network.BA_nodes, pos, network_id, false)
elseif eu_type == "SPECIAL" and from_below and
not vector.equals(pos, sw_pos) then
-- Another switching station -> disable it
add_network_node(network.SP_nodes, pos, network_id)
add_network_node(network.SP_nodes, pos, network_id, false)
meta:set_int("active", 0)
end

Expand Down