Strategies for moving electricity between surfaces?

Place to get help with not working mods / modding interface.
Post Reply
torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Strategies for moving electricity between surfaces?

Post by torne »

I'm trying to make a mod which uses multiple surfaces as "floors" and I want to be able to transport things between floors. I've been using the very neat Factorissimo code as a reference for some general strategies for this and I have a working implementation for items and liquids, but electricity is proving tricky.

Factorissimo handles electricity by having the "factory" building be a roboport, which causes the game engine to charge the roboport's energy buffer, and then it reflects the state of that buffer into an accumulator inside the factory to be the energy source for machines inside the factory. This makes sense and works fine for Factorissimo because the type of the building isn't particularly important, and each building is connected to just one surface. It looks like it does the reverse for power generation buildings.

This means you have to decide a fixed "direction" that power can flow for each connection, and there's also no way to see "global" power stats since each surface has its own electric network. Are there any other strategies for transferring power between surfaces that people know of, or have been used in other mods? I suspect it's not possible in the current game engine to have this work "perfectly", but any alternative suggestions would be interesting to compare the upsides and downsides. :)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Strategies for moving electricity between surfaces?

Post by Rseding91 »

The game doesn't allow different surfaces to connect electric energy sources. They're specifically coded to only work with one surface.
If you want to get ahold of me I'm almost always on Discord.

torne
Filter Inserter
Filter Inserter
Posts: 341
Joined: Sun Jan 01, 2017 11:54 am
Contact:

Re: Strategies for moving electricity between surfaces?

Post by torne »

Yeah, I guessed that was probably the case looking at the API - thanks for confirming it. So, I'm just curious what other hacky workarounds people might have thought of other than the method Factorissimo uses :)

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Strategies for moving electricity between surfaces?

Post by darkfrei »

You can made two accumulators, one have input only, second have output only. Take the energy from first and set in the second with simple script.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Strategies for moving electricity between surfaces?

Post by Yoyobuae »

torne wrote:Yeah, I guessed that was probably the case looking at the API - thanks for confirming it. So, I'm just curious what other hacky workarounds people might have thought of other than the method Factorissimo uses :)
Using electrical-energy-interface entity. It's a similar to accumulator, except that it also allows changing power generated/consumed dynamically. So via LUA one can consume power at one such entity and produce it in another.

A while back I made a mod as a proof of concept of sorts:
https://mods.factorio.com/mods/Yoyobuae ... ransformer

The electric network window still shows it as the producer/consumer though (no way around that). The benefit is that the power used at the consuming side is reflected back into the producer side. It's a bit tricky to ensure energy is not created/destroyed in the process, but I think my code should work correctly.

cakeistasty
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Jan 18, 2024 6:45 pm
Contact:

Re: Strategies for moving electricity between surfaces?

Post by cakeistasty »

fyi for anyone lost in old forums this is now possible :D just run connect_neighbor onto another pole on the other surface

Post Reply

Return to “Modding help”