mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-24 18:00:29 +01:00
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:
parent
d4609f23f2
commit
6a9dfec36f
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user