Attach new machines and cables to touched networks

This commit is contained in:
2023-11-14 11:46:30 +01:00
parent c3b49b68e1
commit 340c46bf48
3 changed files with 35 additions and 16 deletions

View File

@@ -15,6 +15,20 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local cable={}
cable.onConstruct=function(pos)
local connections=industrialtest.api.getConnections(pos)
for _,conn in ipairs(connections) do
local meta=minetest.get_meta(conn)
local networks=industrialtest.api.isAttachedToNetwork(meta)
if networks then
for _,network in ipairs(networks) do
industrialtest.api.createNetworkMapForNode(network)
end
end
end
end
local function registerCable(name,displayName,size,flow,registerInsulated)
local definition={
@@ -88,7 +102,8 @@ local function registerCable(name,displayName,size,flow,registerInsulated)
"group:_industrialtest_hasPowerInput",
"group:_industrialtest_hasPowerOutput",
"group:_industrialtest_cable"
}
},
on_construct=cable.onConstruct
}
if industrialtest.mtgAvailable then
definition.groups={