Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Jan 02, 2025 8:51 pm
by braxbro
Hi. I wrote a long preamble for why I'd like this, which is in a spoiler block below for brevity.
TLDR - Linked connections for both items and fluids exist - and for items, have for a while
We've had Linked Belts and Linked Chests for a fair bit. (both were present in 1.1; I don't know how much older than that they are because 1.0 and before were documented on the wiki, and the wiki docs have been removed and redirected to the new API reference, which only covers 1.1 and 2.0)
Both are tremendously useful for both modded cross-surface purposes and various niche custom stuff dealing with compound entities, though internal (pointed inside of the entity's hitbox) fluid connections were arguably a superior, if ugly, alternative at the time for compound entity use cases.
We've also had the (less useful, but still useful) ability to connect power poles by script, ignoring surface/distance restrictions, allowing for the creation of cross-surface power poles for a while as well. (AAI Signal Transmission and notnotmelon's fork of Factorissimo both use this)
In 2.0, we got the 'Linked' connection type for fluid box connections, alleviating the ugliness of internal fluid connections in compound entities, and enabling both more complex compound entities and the creation of linked pipes. We also got vector_to_place_result for all assemblers, furnaces, and rocket silos, (as nonsensical as it might be for the latter) where it was previously limited to mining drills, which can be useful for compound entities by enabling the automatic output of items into other parts of the entity. (though I don't know if it works when the vector is inside of the entity's hitbox...?)
Both of these now make it easier than ever to build compound entities with various behaviors that aren't seen in the base game, significantly raising the ceiling for what mods can do without having to rely on Lua scripting hacks.
As of right now, there are only two aspects (that I can think of) of an entity that can't be linked in this manner: energy sources and heat connections. The latter can be addressed, as far as I know, through 1.1-style internal heat connections for compound entity applications. (but not for pseudo-underground heat pipes or cross-surface heat connections; those in theory can be hacked together with two assemblers creating a dummy fluid and two reactor prototypes consuming it using linked fluid boxes to connect them and a script to disable the reactors above a certain heat cap)
The former cannot. The best you can do right now is integrate a power pole into your compound entity and forbid placing power poles such that their connection area overlaps with the entity, or use linked connections to put all the energy source stuff on another surface. (which doesn't work if one of the components needs to be at the location of the compound entity... such as, say, a lightning rod)
So I propose the creation of a linked energy source type that functions as an electric energy source that only connects via control-stage script. This energy source would be available for prototypes anywhere an electric energy source is available. (maybe it should be a runtime thing or a property of electric energy sources?) For a full list, in case others are unaware, you can look at the api reference for ElectricEnergySources.
This would enable many things that aren't currently feasible without Lua scripting, hopefully in a less intrusive manner than, for example, adding fluid energy sources to entities that can only use void or electric energy inputs, or adding optional fluid/heat outputs to generator prototypes that don't already support them.
Example ideas enabled as compound entities by linked energy sources
Solars that output heat, steam, or the like (There are a few heat-based solar mods already; this would likely make them more performance friendly.)
Lightning rods that output heat, steam, or the like (I want to make a steam-based lightning rod that explodes when it gets full!)
Fusion reactors that output heat, steam or the like (while still properly maintaining a coolant loop; recipes cannot be fully aware of fluid temperature variance without an ungodly number of prototypes)
Lamps that run on oil/combustibles, I guess?
Burner/fluid/heat powered roboports (IR3 had steam canister-powered personal roboports; having a steam powered non-personal roboport may be something modders would be interested in)
Burner equivalents to laser/flame turrets, I guess???
Asteroid collectors that require lubrication???
Maybe personal grid equipment that runs off of the base's power grid or links to it??? That's kinda a stretch, but still...
Sorry for the huge write-up. I just had a thought and it kept going and going like a clown/magician pulling a chain of handkerchiefs out of their sleeve...
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Fri Jan 03, 2025 9:11 pm
by BraveCaperCat
It doesn't make any sense for there to not be linked energy sources. I mean, there's already linked belts, linked containers/chests and linked fluid boxes/pipes, why not linked energy connectors? (or linked energy sources, receivers, etc)
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Fri Jan 03, 2025 9:23 pm
by curiosity
BraveCaperCat wrote: Fri Jan 03, 2025 9:11 pm
It doesn't make any sense for there to not be linked energy sources. I mean, there's already linked belts, linked containers/chests and linked fluid boxes/pipes, why not linked poles? (or linked energy connectors, sources, etc)
Poles can already be linked. But the OP explicitly explains that poles aren't a solution and why.
Actually, what might help with the OP problem, if not linked energy sources, is electric network categories. Entities from different categories don't connect. It makes the power pole solution viable.
Re: Linked Energy Sources/Script-Controlled Electric Networks
BraveCaperCat wrote: Fri Jan 03, 2025 9:11 pm
It doesn't make any sense for there to not be linked energy sources. I mean, there's already linked belts, linked containers/chests and linked fluid boxes/pipes, why not linked poles? (or linked energy connectors, sources, etc)
Poles can already be linked. But the OP explicitly explains that poles aren't a solution and why.
Actually, what might help with the OP problem, if not linked energy sources, is electric network categories. Entities from different categories don't connect. It makes the power pole solution viable.
When I posted my reply, I hadn't read the actual original post. Instead, I read about it in a few sentences elsewhere, which linked here. Those few sentences (unlike the "quite a lot" amount of sentences used here) didn't explain that linked poles were different from linked energy sources or that they couldn't fulfil the same purposes.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Poles can already be linked. But the OP explicitly explains that poles aren't a solution and why.
Actually, what might help with the OP problem, if not linked energy sources, is electric network categories. Entities from different categories don't connect. It makes the power pole solution viable.
They are a solution, the issue is that the constraints on that solution are terribly awkward to work with and unintuitive for the player overall.
If you don't forbid electric network stuff near the compound machine with the power pole in it, then they may be confused, for example, when they see their boiler lightning rod (which is an idea that I had for a mod I intend to make that this would facilitate) drawing a ridiculous amount of energy because their power poles were placed too close. And if you do, you make it terribly inconvenient to work around the compound entity, which sucks.
Having the ability to set electric network 'layers' of sorts would also fulfill this feature request, though, you are right. (Hell, even just being able to override electric network connections for electric energy sources directly would cover it, tbh.)
Re: Linked Energy Sources/Script-Controlled Electric Networks
Poles can already be linked. But the OP explicitly explains that poles aren't a solution and why.
Actually, what might help with the OP problem, if not linked energy sources, is electric network categories. Entities from different categories don't connect. It makes the power pole solution viable.
They are a solution, the issue is that the constraints on that solution are terribly awkward to work with and unintuitive for the player overall.
If you don't forbid electric network stuff near the compound machine with the power pole in it, then they may be confused, for example, when they see their boiler lightning rod (which is an idea that I had for a mod I intend to make that this would facilitate) drawing a ridiculous amount of energy because their power poles were placed too close. And if you do, you make it terribly inconvenient to work around the compound entity, which sucks.
Having the ability to set electric network 'layers' of sorts would also fulfill this feature request, though, you are right. (Hell, even just being able to override electric network connections for electric energy sources directly would cover it, tbh.)
What if you made a power pole with a connection radius of 0 and a supply area of 1? (or more if that's not enough, it just needs to be able to cover the combined entity)
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Fri Jan 03, 2025 10:40 pm
by curiosity
BraveCaperCat wrote: Fri Jan 03, 2025 10:25 pm
What if you made a power pole with a connection radius of 0 and a supply area of 1? (or more if that's not enough, it just needs to be able to cover the combined entity)
It's not the power pole that's the problem, it's every other power pole with its own supply area.
Re: Linked Energy Sources/Script-Controlled Electric Networks
What if you made a power pole with a connection radius of 0 and a supply area of 1? (or more if that's not enough, it just needs to be able to cover the combined entity)
Entities can connect to multiple electric networks at once, and have no means of prioritizing between the two. This can be most easily seen by placing accumulators bridging two disconnected power networks; they serve as a sort of flow control for power between the two networks as one network charges them and the other draws from them. The receiving network(s) can never receive more than the accumulators can discharge, and the charging network(s) can never contribute more than the accumulators can accept.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Sat Jan 04, 2025 12:51 am
by protocol_1903
+1, I've run into similar issues with compound entities that a generic linked energy source like the one mentioned would solve
Re: Linked Energy Sources/Script-Controlled Electric Networks
What if you made a power pole with a connection radius of 0 and a supply area of 1? (or more if that's not enough, it just needs to be able to cover the combined entity)
Entities can connect to multiple electric networks at once, and have no means of prioritizing between the two. This can be most easily seen by placing accumulators bridging two disconnected power networks; they serve as a sort of flow control for power between the two networks as one network charges them and the other draws from them. The receiving network(s) can never receive more than the accumulators can discharge, and the charging network(s) can never contribute more than the accumulators can accept.
Yeah, I'm not very good with control scripting. Or electricity management. (best I can do is set a reactor to stop receiving nuclear fuel when it has too high a temperature or there's already fuel)
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Wed Jul 30, 2025 1:15 am
by braxbro
Bumping this because it’d be very useful
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Wed Jul 30, 2025 1:37 am
by Rseding91
I don’t understand how this would work. What would it mean when an entity has a “linked energy source”? What doesn’t link to? How does it interact with anything?
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Wed Jul 30, 2025 2:24 am
by curiosity
Rseding91 wrote: Wed Jul 30, 2025 1:37 am
I don’t understand how this would work. What would it mean when an entity has a “linked energy source”? What doesn’t link to? How does it interact with anything?
I'm guessing linked electric sources and sinks. You have only yourselves to blame for this confusing terminology.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Fri Aug 01, 2025 2:40 am
by protocol_1903
For an actually helpful answer,
Energy sources as a separate entity prototype, that then connect to a 'linked energy source' for a specific entity, just like one connects linked belts, containers, and pipes. This energy source then provides power for that entity, with all of the normal restrictions.
Alternatively, though i doubt this implementation however cool it may be, multiple of the same linked energy source prototype can be linked so that all power/pull power from the same 'pool' of resources.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Aug 07, 2025 4:29 am
by braxbro
Rseding91 wrote: Wed Jul 30, 2025 1:37 am
I don’t understand how this would work. What would it mean when an entity has a “linked energy source”? What doesn’t link to? How does it interact with anything?
I would just say make a new EnergySource type that can explicitly link to other sources, or add the functionality to do it directly to ElectricEnergySources.
The point of a linked energy source is to make an entity with an energy source that does not interact with player-built power networks - only script-defined ones. So you could, for example, place a lightning rod with a linked energy source next to a power pole and the network would get no power, but another entity linked to it by script would. The other entity also would not take power from the network.
It interacts with things when those things are directly connected via script, akin to how linked chests, belts, and fluid boxes work. The whole point of this would be to enable more granular compound entity functionality while keeping the vanilla power network windows unaffected, among other use cases outlined in the OP.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Aug 07, 2025 12:11 pm
by Rseding91
I'm still not understanding how it would actually function. When you say "link to an entity" exactly what does that mean? Does it mean "Entity A, with the linked energy source, will extract energy from entity B, the linked-to entity, when entity A needs to consume energy"? Because then what about entity B and it's energy source? In this example, if it's electric it would already be connecting to any nearby poles and working as normal to produce/consume electricity from the network. Or would it *also* be a linked energy source type - but then if it's not "linked to" anything where does it get any energy from/produce into?
That's what I'm missing. Just saying "linked energy source" means nothing in terms of energy sources without this defined.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Aug 07, 2025 1:54 pm
by braxbro
Rseding91 wrote: Thu Aug 07, 2025 12:11 pm
I'm still not understanding how it would actually function. When you say "link to an entity" exactly what does that mean? Does it mean "Entity A, with the linked energy source, will extract energy from entity B, the linked-to entity, when entity A needs to consume energy"? Because then what about entity B and it's energy source? In this example, if it's electric it would already be connecting to any nearby poles and working as normal to produce/consume electricity from the network. Or would it *also* be a linked energy source type - but then if it's not "linked to" anything where does it get any energy from/produce into?
That's what I'm missing. Just saying "linked energy source" means nothing in terms of energy sources without this defined.
The idea is that you explicitly connect entities into a network, independent of player-placed electric networks. You say “Entity A, I’d like you to be connected to Entity B.” Then, Entity A and B are connected, and if A produces power, B can consume it (or vice versa). I could see either allowing them to be manually connected to electric networks or forcing them to go through an intermediate step to connect to them, but the whole point of the process is to create a system where Entity A and B can connect to each other WITHOUT connecting to an electric network placed around them unless configured to do so.
I would not expect the ability to connect linked energy sources to electric sources directly - ex. an assembler mooching off of a fusion reactor’s energy source. I would more expect the ability to connect linked energy sources to each other in a 1 to 1 or 1 to many configuration, and possibly allowing the option of connecting these script-controlled networks to existing networks by linking them to a power pole - however, this particular interaction is unnecessary and may be best left out for streamlining reasons, as you could simply make part of the compound entity not use a linked energy source to allow the compound entity to draw from or output to an electric network as normal.
In very short, I’d like to be able to create a ‘second layer’ of energy networks with these, where I control connections to the network on an entity-by-entity basis through script, so I don’t contaminate the first layer of power pole-based electric networks.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Aug 07, 2025 2:13 pm
by Rseding91
I see. It’s not “linked to each other” linking, but essentially “electric energy source that uses its own network for power distribution”.
Re: Linked Energy Sources/Script-Controlled Electric Networks
Posted: Thu Aug 07, 2025 4:44 pm
by braxbro
Rseding91 wrote: Thu Aug 07, 2025 2:13 pm
I see. It’s not “linked to each other” linking, but essentially “electric energy source that uses its own network for power distribution”.
Right - but you control the connections directly.
Hence the second alternate name for the suggestion - 'script-controlled electric networks'. While I'm sure there's some SUPREME jank you could make with true linked energy sources (akin to linked chests/pipes where energy sources can become one-to-many w.r.t. entities) the actual use cases I could think of only need the ability to control connections to other energy sources (which is usually handled through an electric network for power distribution)
I suppose it's more like having an item output or fluid connection location on an entity that's within that entity's hitbox, so it dumps to another part of the compound entity instead of to the outside. That was the kind of conceptual role I was trying to describe.