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.
Get entity connections?
-
- Inserter
- Posts: 29
- Joined: Wed Apr 29, 2020 9:53 pm
- Contact:
Re: Get entity connections?
https://lua-api.factorio.com/latest/Lua ... neighbours
https://lua-api.factorio.com/latest/Lua ... d_entities
https://lua-api.factorio.com/latest/Lua ... efinitions
You'll need that last one for connecting to combinators (because they have two connection points).
https://lua-api.factorio.com/latest/Lua ... d_entities
https://lua-api.factorio.com/latest/Lua ... efinitions
You'll need that last one for connecting to combinators (because they have two connection points).
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
-
- Inserter
- Posts: 29
- Joined: Wed Apr 29, 2020 9:53 pm
- Contact:
Re: Get entity connections?
Thanks.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Get entity connections?
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Get entity connections?
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?
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?
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.Silari wrote: ↑Sat May 15, 2021 8:47 amconnect_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.
Edit: See attached image
- Attachments
-
- link breaks.png (856.59 KiB) Viewed 2765 times
Re: Get entity connections?
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}
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?
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.Silari wrote: ↑Sat May 15, 2021 7:41 pmAh 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.worked to connect a wall to an electric pole via red wire when I tested it.Code: Select all
awallnexttoagate.connect_neighbour{wire = defines.wire_type.red, target_entity = anearbyelectricpole}
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.