connect_neighbour and disconnect_neighbour for Power Switch

Post Reply
Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

connect_neighbour and disconnect_neighbour for Power Switch

Post by Yoyobuae »

Simple enough. Make this two API methods work for power switches:
http://lua-api.factorio.com/latest/LuaE ... _neighbour
http://lua-api.factorio.com/latest/LuaE ... _neighbour

This would enable creating a mod for auto connecting power switches to power poles, which is an often requested feature (specially in relation to blueprinting).

Basically the API should allow specifying copper wire to be used when connecting a power switch entity with a power pole (or the other way around). The source_circuit_id (or target_circuit_id) parameter could naturally refer to the left/right sides of the power switch.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: connect_neighbour and disconnect_neighbour for Power Switch

Post by PFQNiet »

You know when you search something on Google and find someone else with the same idea as you from years ago?

This is one of those moments. Is this possible? I'd love to have this feature.

Readily anticipated issue: you have to specify which side of the Power Switch to connect to. This could probably be done just by allowing defines.wire_type.copper but only if connecting (power pole, power pole) or (power pole, power switch).

I know Power Switches don't get much love but there's so much potential here!

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: connect_neighbour and disconnect_neighbour for Power Switch

Post by Rseding91 »

Added for 1.1.
If you want to get ahold of me I'm almost always on Discord.

Natha
Fast Inserter
Fast Inserter
Posts: 173
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: connect_neighbour and disconnect_neighbour for Power Switch

Post by Natha »

I have a question related to this topic.

How can you read the copper connections of a power switch? When using "circuit_connection_definitions", it gives you all connected poles but not which side of the switch (just -1 for source_circuit_id and target_circuit_id).

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2227
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: connect_neighbour and disconnect_neighbour for Power Switch

Post by boskid »

API for power switches in 1.1.x is quite limited, i see no clean way of finding which side of a power switch is connected to an electric pole. Only usable information here is that if a power switch is connected to 2 electric poles, the LuaEntity::neighbours in the "copper" output will return 2 electric poles: [1] is for left and [2] is for right connection. If there is only one pole connected it will take an index [1] in the copper table in which case it may not be possible to resolve side directly. This will be easy to do in 1.2.x.

Post Reply

Return to “Implemented mod requests”