Get entity connections?

Place to get help with not working mods / modding interface.
thesixthroc
Inserter
Inserter
Posts: 29
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Get entity connections?

Post by thesixthroc »

I’m moving some power poles between surfaces, which involves .clone() because they don’t support .teleport().

Power poles are often disconnected during the process, and I could reconnect them with .connect_neighbour(), but I haven’t managed to find out how to query the power poles before moving for which neighbours they have.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 695
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Get entity connections?

Post by Xorimuth »

My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
thesixthroc
Inserter
Inserter
Posts: 29
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Re: Get entity connections?

Post by thesixthroc »

Thanks.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Get entity connections?

Post by eradicator »

If you're copying large areas it might be easier to create a blueprint which automatically handles entity properties (and also modded entity properties). Then you "only" have to deal with reviving the ghosts.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: Get entity connections?

Post by vedrit »

I'm trying to maintain wall/gate connections in my mod, but using connect_neighbour doesn't seem to be working. Is there something special I have to do for walls/gates?
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 531
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Get entity connections?

Post by Silari »

vedrit wrote: Sat May 15, 2021 8:28 am I'm trying to maintain wall/gate connections in my mod, but using connect_neighbour doesn't seem to be working. Is there something special I have to do for walls/gates?
connect_neighbor says it's for electric/circuit wires. Pretty sure for walls the game automatically makes the connections they can have, since they're always connected. A quick test with .clone() shows the game makes the connections perfectly fine without anything else.
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: Get entity connections?

Post by vedrit »

Silari wrote: Sat May 15, 2021 8:47 am
vedrit wrote: Sat May 15, 2021 8:28 am I'm trying to maintain wall/gate connections in my mod, but using connect_neighbour doesn't seem to be working. Is there something special I have to do for walls/gates?
connect_neighbor says it's for electric/circuit wires. Pretty sure for walls the game automatically makes the connections they can have, since they're always connected. A quick test with .clone() shows the game makes the connections perfectly fine without anything else.
connect_neighbour also connects two devices. And in case there's confusion, I'm not talking about connections between walls, I'm talking about if you have a wire from a wall/gate to the network for reading or controlling gate state.

Edit: See attached image
Attachments
link breaks.png
link breaks.png (856.59 KiB) Viewed 2765 times
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 531
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Get entity connections?

Post by Silari »

vedrit wrote: Sat May 15, 2021 8:52 am connect_neighbour also connects two devices. And in case there's confusion, I'm not talking about connections between walls, I'm talking about if you have a wire from a wall/gate to the network for reading or controlling gate state.

Edit: See attached image
Ah yeah I was reading that as the connections that walls show when they're next to things. Shouldn't be anything particularly special about how walls/gates get connected.

Trying it, I'm not having any issues connecting a wall attached to a gate to an electric pole via connect_neighbour.

Code: Select all

awallnexttoagate.connect_neighbour{wire = defines.wire_type.red, target_entity = anearbyelectricpole}
worked to connect a wall to an electric pole via red wire when I tested it.
poleconnection.png
poleconnection.png (177.76 KiB) Viewed 2723 times

Are you trying to connect one of the gate pieces or the wall next to it? Factorio seems to expect you to connect to a wall next to the gate, and if you try to use it with a gate it complains about not having a circuit id - i haven't found a value that works for that. It's also wonky if you hook up a wall without a gate next to it, so the order you do things in might also be a problem. Otherwise, is the game giving you any kind of errors when you're trying to do your connections?

EDIT: also it's possibly a weird interaction with something else you're doing at the time. My tests were with preexisting stuff, no moving/cloning involved.
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: Get entity connections?

Post by vedrit »

Silari wrote: Sat May 15, 2021 7:41 pm
vedrit wrote: Sat May 15, 2021 8:52 am connect_neighbour also connects two devices. And in case there's confusion, I'm not talking about connections between walls, I'm talking about if you have a wire from a wall/gate to the network for reading or controlling gate state.

Edit: See attached image
Ah yeah I was reading that as the connections that walls show when they're next to things. Shouldn't be anything particularly special about how walls/gates get connected.

Trying it, I'm not having any issues connecting a wall attached to a gate to an electric pole via connect_neighbour.

Code: Select all

awallnexttoagate.connect_neighbour{wire = defines.wire_type.red, target_entity = anearbyelectricpole}
worked to connect a wall to an electric pole via red wire when I tested it.
poleconnection.png


Are you trying to connect one of the gate pieces or the wall next to it? Factorio seems to expect you to connect to a wall next to the gate, and if you try to use it with a gate it complains about not having a circuit id - i haven't found a value that works for that. It's also wonky if you hook up a wall without a gate next to it, so the order you do things in might also be a problem. Otherwise, is the game giving you any kind of errors when you're trying to do your connections?

EDIT: also it's possibly a weird interaction with something else you're doing at the time. My tests were with preexisting stuff, no moving/cloning involved.
Found out that the issue I've got is likely a bug someone else found. If you fast replace a gate, by hand or by script, the circuit connection breaks.
Post Reply

Return to “Modding help”