Page 1 of 1

Get entity connections?

Posted: Fri Apr 30, 2021 9:14 pm
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.

Re: Get entity connections?

Posted: Fri Apr 30, 2021 9:18 pm
by Xorimuth

Re: Get entity connections?

Posted: Thu May 06, 2021 4:50 pm
by thesixthroc
Thanks.

Re: Get entity connections?

Posted: Thu May 06, 2021 8:21 pm
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.

Re: Get entity connections?

Posted: Sat May 15, 2021 8:28 am
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?

Re: Get entity connections?

Posted: Sat May 15, 2021 8:47 am
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.

Re: Get entity connections?

Posted: Sat May 15, 2021 8:52 am
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

Re: Get entity connections?

Posted: Sat May 15, 2021 7:41 pm
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 2725 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.

Re: Get entity connections?

Posted: Sat May 15, 2021 9:29 pm
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.