Batteries: Workaround to fix discharge (#609)

The network traversal code does still not handle connecting sides,
but at least finite power is no more.
This commit is contained in:
SmallJoker 2022-10-29 21:36:48 +02:00 committed by GitHub
parent d4609f23f2
commit 6a9dfec36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -192,10 +192,10 @@ function technic.register_battery_box(data)
end end
local run = function(pos, node) local run = function(pos, node)
local below = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local network_id = tonumber(meta:get_string(tier.."_network"), 16)
if not technic.is_tier_cable(below.name, tier) then if not technic.networks[network_id] then
meta:set_string("infotext", S("%s Battery Box Has No Network"):format(tier)) meta:set_string("infotext", S("%s Battery Box Has No Network"):format(tier))
return return
end end

View File

@ -69,7 +69,7 @@ local function clear_networks(pos)
elseif technic.machines[tier][node.name] then elseif technic.machines[tier][node.name] then
-- Found a machine -- Found a machine
local eu_type = technic.machines[tier][node.name] local eu_type = technic.machines[tier][node.name]
meta:set_string(tier.."_network", minetest.pos_to_string(sw_pos)) meta:set_string(tier.."_network", string.format("%X", network_id))
if eu_type == technic.producer then if eu_type == technic.producer then
table.insert(network.PR_nodes, pos) table.insert(network.PR_nodes, pos)
elseif eu_type == technic.receiver then elseif eu_type == technic.receiver then

View File

@ -133,7 +133,8 @@ local check_node_subp = function(network, pos, machines, sw_pos, from_below, net
--dprint(name.." is a "..machines[name]) --dprint(name.." is a "..machines[name])
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string(network.tier.."_network", minetest.pos_to_string(sw_pos)) -- Normal tostring() does not have enough precision, neither does meta:set_int()
meta:set_string(network.tier.."_network", string.format("%X", network_id))
if eu_type == technic.producer then if eu_type == technic.producer then
add_network_node(network.PR_nodes, pos, network_id) add_network_node(network.PR_nodes, pos, network_id)