Connecting entities by copper wire but not autoconnect to power poles
Connecting entities by copper wire but not autoconnect to power poles
I was wondering if I can make entities that can be connected by copper wire in some way that the LUA script can trace. Given one entity I need to find connected entities. And because I don't want to end up getting all power poles I don't want any automatic copper wire connections being made.
Note: The visible entity already has a train-stop, a hidden constant combinator, a visible constant combinator, a lamp and a wooden chest. So I'm not afraid to add some more to make it work best.
Note: The visible entity already has a train-stop, a hidden constant combinator, a visible constant combinator, a lamp and a wooden chest. So I'm not afraid to add some more to make it work best.
Re: Connecting entities by copper wire but not autoconnect to power poles
Not sure I've understood that correctly, but couldn't you make a new electric-pole prototype and filter for that prototype's name? You can then check LuaEntity.neighbours and remove unwanted connections.mrvn wrote: ↑Tue Nov 02, 2021 11:59 pm I was wondering if I can make entities that can be connected by copper wire in some way that the LUA script can trace. Given one entity I need to find connected entities. And because I don't want to end up getting all power poles I don't want any automatic copper wire connections being made.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Connecting entities by copper wire but not autoconnect to power poles
If I place two entities on each side of the base and they automatically connect to existing power poles with a copper wire then there is a near unity chance they end up being connected by copper wire. That must not happen. I only want connections placed manually by the player or by blueprints.
If I have to I can use red/green wires but those are useful for carrying signals. Using one wire to connect my entities would a) transmit signals from one entity to the other and b) only leave one other color to read/send signals. So I'm hoping to use the copper wire as a neutral wire.
If I have to I can use red/green wires but those are useful for carrying signals. Using one wire to connect my entities would a) transmit signals from one entity to the other and b) only leave one other color to read/send signals. So I'm hoping to use the copper wire as a neutral wire.
Re: Connecting entities by copper wire but not autoconnect to power poles
viewtopic.php?f=28&t=99778 related
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
Re: Connecting entities by copper wire but not autoconnect to power poles
I think it means you will need some thing like thismrvn wrote: ↑Fri Nov 05, 2021 3:01 pm If I place two entities on each side of the base and they automatically connect to existing power poles with a copper wire then there is a near unity chance they end up being connected by copper wire. That must not happen. I only want connections placed manually by the player or by blueprints.
If I have to I can use red/green wires but those are useful for carrying signals. Using one wire to connect my entities would a) transmit signals from one entity to the other and b) only leave one other color to read/send signals. So I'm hoping to use the copper wire as a neutral wire.
Code: Select all
local fucntion on_pole_built(in_pole_entity)
local lname="lonely-power-pole";
if in_pole_entity.name==lname then
in_pole_entity.disconnect_neighbour(defines.wire_type.copper);
else
for _,e in pairs(in_pole_entity.neighbours["copper"])
if(e.name==lname) then
e.disconnect_neighbour{wire=defines.wire_type.copper,entity=in_pole_entity};
end
end
end
return;
end
Re: Connecting entities by copper wire but not autoconnect to power poles
That won't work if the blueprint has a copper wire going from lonely-power-pole to power-pole to other lonely-power-pole.
But maybe I could avoid that middle pole by providing a tool to connect 2 lonely-power-pole with a copper wire regardless of their distance. I could then set the wire reach of lonely-power-pole to 0 so it doesn't connect with anything automatically.
Can I make a tool to select lonely-power-pole for connection?
Update: Just tried that idea. Power poles with wire reach 0 will keep their wires when you load the game but when you place a blueprint the wire disappears. So at a minimum I have to store the wire connections in the blueprint as tags and then recreate the wires when the blueprint gets placed.
I guess now I have to learn about making a tool.
But maybe I could avoid that middle pole by providing a tool to connect 2 lonely-power-pole with a copper wire regardless of their distance. I could then set the wire reach of lonely-power-pole to 0 so it doesn't connect with anything automatically.
Can I make a tool to select lonely-power-pole for connection?
Update: Just tried that idea. Power poles with wire reach 0 will keep their wires when you load the game but when you place a blueprint the wire disappears. So at a minimum I have to store the wire connections in the blueprint as tags and then recreate the wires when the blueprint gets placed.
I guess now I have to learn about making a tool.
Re: Connecting entities by copper wire but not autoconnect to power poles
Do you place the two lonely-power-poles per script? In this case, you should be able to connect them per script even if they are farther away than the prototype's wire reach allows. Obviously, that won't work if the poles are placed by players.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Connecting entities by copper wire but not autoconnect to power poles
Initially the poles would be placed by script when the main entity is build. On blueprints the idea was that the pole would be included to preserve the wire connections. So the ghosts of poles would be build by blueprint and revived when the main entity is build.
The wire disappears when I place the blueprint. I have yet to test if I can connect 2 ghosts with wires and have the wire appear when the poles get revived.
Update: ghost_pole.connect_neighbour(other_ghost_pole) returns false and no wire appears. At least outside the wire reach. How do I connect 2 entities past their wire reach?
Re: Connecting entities by copper wire but not autoconnect to power poles
so there`s 2 thing
1.disconnected the lonely power pole when built
2.keep connection in blueprint
so I think it can be something like this
1.disconnected the lonely power pole when built
2.keep connection in blueprint
so I think it can be something like this
Code: Select all
func on_built(inentity)
{
func handle_pole(ine)
{
if(is_registered(ine))
recover_state(ine);
else
ine.disconnect();
};
if(inentity==ghost and inentity.ghost_name==lonely-power-pole)
{
register_state(inentity);
return;
}
if(inentity==lonely-power-pole)
{
handle_pole(inentity);
return;
}
for _,e in pairs(inentity.connected)
if(e==lonely-power-pole)
handle_pole(e);
return;
}
Re: Connecting entities by copper wire but not autoconnect to power poles
Read the teleport documentation more carefully.
Re: Connecting entities by copper wire but not autoconnect to power poles
is there a full list? or I should test it and maintain it in wiki ?
Re: Connecting entities by copper wire but not autoconnect to power poles
Sorry, my mistake. The thing I (wrongly) remembered was from a problem I had with Picker dollies: When one of my base entities was moved, I had to move (teleport) its other entities as well. One of these was a power pole, and when I moved a connected pole, the wire could be stretched beyond max_wire_distance, so I had to cut the connection. I just tested: You can't make a connection for distances exceeding max_wire_distance. But creating both entities within reach of each other and then teleporting them to their final positions would work.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Connecting entities by copper wire but not autoconnect to power poles
The goal of it is to make it easy for the user to connect the entities and to preserve the connection in blueprints. This fails at both of those goals.
If I have to do all the connecting and connections in LUA and working around the game then I can just use LuaRendering.draw_line instead of wires.
If I have to do all the connecting and connections in LUA and working around the game then I can just use LuaRendering.draw_line instead of wires.