Page 1 of 1

Secondary "Power" Grid

Posted: Tue May 17, 2022 1:11 am
by EpicSmashMan
is the electrical grid programmed into the base game?
I'm trying to create a secondary grid that works exactly like the power grid but runs off a different resource, a plasma grid.
The issue I'm running into is there doesn't appear to be a way to create such a thing.

Is it impossible? or would I have to fudge it with a fluid grid?

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 1:47 am
by robot256
Electric grid is a hard-coded behavior. You can have any number of actual grids on the map, where each grid is a group of electric poles that don't connect to poles in any other grid.

Electric pole wiring can be changed by scripts, so in theory you could have your mod's scripts make sure that the "plasma poles" only ever connect to each other, and always form an electric grid that never touches the main grid. But it would still receive and supply power from any entities within its supply area. (If two different grids touch the same entity, they share the load.)

Here is a reference to take a look at that uses (abuses) the fluid handling system to transmit power, and does not use the built-in electric grid logic at all. The pipes are all invisible to the user. https://mods.factorio.com/mod/FluidicPower

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 2:23 am
by EpicSmashMan
robot256 wrote:
Tue May 17, 2022 1:47 am
Electric grid is a hard-coded behavior. You can have any number of actual grids on the map, where each grid is a group of electric poles that don't connect to poles in any other grid.

Electric pole wiring can be changed by scripts, so in theory you could have your mod's scripts make sure that the "plasma poles" only ever connect to each other, and always form an electric grid that never touches the main grid. But it would still receive and supply power from any entities within its supply area. (If two different grids touch the same entity, they share the load.)

Here is a reference to take a look at that uses (abuses) the fluid handling system to transmit power, and does not use the built-in electric grid logic at all. The pipes are all invisible to the user. https://mods.factorio.com/mod/FluidicPower
thanks, I thought as much :cry: guess I'll have to turn it into a fluid system. In that case, is it possible to restrict what fluids can be in a fluid box?

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 6:30 am
by Stringweasel
Yes, it is. You can only filter one type though. This means a FluidBox will only accept one type of fluid, or all of them.

Going the fluids route might be hard to do, because it's a real a pain to work with. Especially where you need to turn electricity into fluid and fluid back into electricity so that all your normal machines work. And this needs to be done at each and every pole. It''s quite slow UPS wise. So my advice is to stay in the electric domain, if it's possible. As robot256 mentioned, then you'd have to manipulate the copper connections between poles, which might be easier.

If you're curious though about Fluidic Power though, I wrote a little about it here: https://alt-f4.blog/ALTF4-51/

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 6:34 am
by Stringweasel
I guess another question you can ask is: what do you want to achieve?

For example, if you go the fluid direction then your plasma grid will not behave like electricity in the sense that it has perfect and instant transmission. Fluids will have to flow through all the poles to get where it needs to be. Is this how you want it to work?

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 9:58 am
by Xorimuth
Hey, I'm the author of another power overhaul mod (Power Overload) so I've thought about these things a bit.

Here's what I'd suggest for your secondary power grid:

Automatically disconnect electric poles from plasma poles whenever they are placed, using a method similar to https://github.com/tburrows13/PowerOver ... lua#L9-L13. Note that you can't prevent the networks being connected for a single tick (viewtopic.php?f=28&t=99778), hopefully that won't matter.

The plasma poles will still take from and provide power to all electric entities in their radius though. My solution for that would be to give all plasma poles a supply area of 0 (https://wiki.factorio.com/Prototype/Ele ... a_distance). Then with some scripting you can add an (invisible) pole entity to every plasma machine that would connect to nearby plasma poles. Since the invisible plasma poles are only placed by script, and only inside entities, they will never be able to power non-plasma machines. This should be fairly seamless for the player, and I think the minor changes it requires would fit into the lore of plasma and makes a nice differentiator between plasma and electricity.

The only problem now is that this doesn't prevent powering plasma machines with electricity. I can think of two solutions: one is to do the same zero-supply-area hack mentioned above for the electric network, but then you lose the plasma-electricity difference and get much worse mod compatibility. Second is to have the plasma network run on several orders of magnitude more power, so you'd need insane amounts of electricity production to power just one plasma building, to the point that it is infeasible/impossible. This means that any plasma building in range of an electric power pole would use up all of the player's electricity so they'd have to avoid that happening. I think this could also fit quite nicely into the lore and provide a nice challenge, but it might require making a new electric pole with a small supply area for precise electric connections for areas with lots of plasma machines.

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 11:30 am
by Stringweasel
Xorimuth wrote:
Tue May 17, 2022 9:58 am
The only problem now is that this doesn't prevent powering plasma machines with electricity.
Another option is to disable your plasma machines when they touch a normal electric pole's coverage, similar to SE's beacon overload system, also mimicked by Beacon Rebalance. You could make it part of the lore, "Plasma generated interrupted by electric interference" or whatever :P IMO that would be much cleaner and easier to maintain than having to change how all electric machines work.

Re: Secondary "Power" Grid

Posted: Tue May 17, 2022 11:34 am
by Xorimuth
Stringweasel wrote:
Tue May 17, 2022 11:30 am
Xorimuth wrote:
Tue May 17, 2022 9:58 am
The only problem now is that this doesn't prevent powering plasma machines with electricity.
Another option is to disable your plasma machines when they touch a normal electric pole's coverage, similar to SE's beacon overload system, also mimicked by Beacon Rebalance. You could make it part of the lore, "Plasma generated interrupted by electric interference" or whatever :P IMO that would be much cleaner and easier to maintain than having to change how all electric machines work.
Oh yes, that could work, at the cost of yet-more scripting! I wasn't really suggesting changing all the electric machines, more so my second suggestion of plasma power orders of magnitudes higher (though idk how high factorio's power can go). Your suggestion would definitely work well too.

Re: Secondary "Power" Grid

Posted: Wed May 18, 2022 5:53 pm
by EpicSmashMan
Thanks for all the advice! it's all very helpful and gives me a direction to go on.
Time to see if I can make it work :D