Making entity electric flow fields writable

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Raeon
Burner Inserter
Burner Inserter
Posts: 16
Joined: Wed Jun 22, 2016 8:55 am
Contact:

Making entity electric flow fields writable

Post by Raeon »

Hi!

With the release of 0.16 I got right around to loading up my own mods to test them out. While fixing my mod https://mods.factorio.com/mods/Raeon/In ... 20Charging however, I found out that the LuaEntity::electric_input_flow_limit and LuaEntity::electric_output_flow_limit fields are no longer writable! With this change, I believe it is no longer possible to easily "draw X joules over Y ticks from a power network" from a mod script, meaning I now have to know the power draw beforehand in order to specify it in the entity prototype (or vary the amount of entities I spawn). Unfortunately, my mod has a quite sophisticated method of determining how much power should be drawn that makes it infeasible to do either of those things without losing functionality or lots of UPS.

I'd love to see any mechanic allowing me to reintroduce this behaviour- be it by making the aforementioned fields writable again, or through the introduction of another (couple of) field(s).

Thanks!
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making entity electric flow fields writable

Post by Rseding91 »

Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
If you want to get ahold of me I'm almost always on Discord.
CmdrKeen
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Tue Sep 29, 2015 9:03 pm
Contact:

Re: Making entity electric flow fields writable

Post by CmdrKeen »

There are other writable fields for the electric energy interface:

http://lua-api.factorio.com/0.15.40/Lua ... ity.energy

--edit: it might be UPS efficient to update the energy field once/second.
Raeon
Burner Inserter
Burner Inserter
Posts: 16
Joined: Wed Jun 22, 2016 8:55 am
Contact:

Re: Making entity electric flow fields writable

Post by Raeon »

CmdrKeen wrote:--edit: it might be UPS efficient to update the energy field once/second.
No worries about that- On default settings my mod only updates once per 15 ticks. Moreover, it can be reconfigured for an even lower interval if needed :D .
CmdrKeen wrote:There are other writable fields for the electric energy interface:

http://lua-api.factorio.com/0.15.40/Lua ... ity.energy
The problem is not so much accessibility in my case, but rather quality. If I would just go about setting a fixed size capacity of my interface (e.g. 100MJ) but cannot modify the flow speed at runtime, then I expect to receive spiking power graphs. As the input flow would be equal to the highest possible under any configuration within my mod (unlimited input flow), you would get really weird power spikes and brownouts in your power network due to suddenly high consumption, followed by zero when the buffer fills up :? .

I actually experienced some problems manipulating power flow in 0.15 and posted a bug report a while ago regarding just that. When an energy consumer was receiving power greater than what a single type of provider could provide, it would apply the input flow limit once per type of provider, resulting in the energy consumer receiving more than it was allowed to per it's specified input flow. This consequently caused the internal buffer to fill up sooner than intended, causing the power usage to stop for an undefined amount of time depending on how much excess power was provided (see viewtopic.php?f=11&t=52516 for the full bug report).
Rseding91 wrote:Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
I'm really glad the energy distribution was optimized and simplified, but on the other hand I'm really sad that this was accomplished at the cost of functionality. I was really hoping the issue would be resolved in 0.16 for good, but unfortunately for me the given solution defeats the purpose of solving the bug linked above.

I'm still eagerly looking for a way to fix my mod without creating spiky power graphs, so please let me know if there's a workaround or if some alternative functionality could be introduced to achieve the same effect :D .
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 583
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: Making entity electric flow fields writable

Post by Reika »

Rseding91 wrote:Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
The online API documentation still state the field to be modifiable, but only for entities of type energy-interface. Is that documentation in need of updating, or is the field being read-only for interfaces as well unintentional?
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making entity electric flow fields writable

Post by Rseding91 »

Reika wrote:
Rseding91 wrote:Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
The online API documentation still state the field to be modifiable, but only for entities of type energy-interface. Is that documentation in need of updating, or is the field being read-only for interfaces as well unintentional?
What online API documentation?
If you want to get ahold of me I'm almost always on Discord.
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 583
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: Making entity electric flow fields writable

Post by Reika »

Rseding91 wrote:
Reika wrote:
Rseding91 wrote:Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
The online API documentation still state the field to be modifiable, but only for entities of type energy-interface. Is that documentation in need of updating, or is the field being read-only for interfaces as well unintentional?
What online API documentation?
http://lua-api.factorio.com/latest/LuaE ... flow_limit
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making entity electric flow fields writable

Post by Rseding91 »

Ah thanks, I've fixed them for 0.16.12.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 583
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: Making entity electric flow fields writable

Post by Reika »

Rseding91 wrote:
Ah thanks, I've fixed them for 0.16.12.
The documentation is unchanged; does that mean the fields should in fact be writable for these entities (contrary to what was implied earlier)?
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14264
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making entity electric flow fields writable

Post by Rseding91 »

Reika wrote:
Rseding91 wrote:
Ah thanks, I've fixed them for 0.16.12.
The documentation is unchanged; does that mean the fields should in fact be writable for these entities (contrary to what was implied earlier)?
0.16.12 isn't out yet.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making entity electric flow fields writable

Post by eradicator »

Rseding91 wrote:Those fields are no longer adjustable runtime due to an optimization around the electric network. It's not likely to change meaning you simply can't do that now.
I have to sadly agree with the OP. This completely breaks the ability to use the EEI for dynamic power consumption without producing brownouts or even blackouts.

I previously had a working reverse-power relay (a one way power transfer system) that was completely circuit controllable. The only way to achieve any amount of granularity in the power transferred without changing the flow_limit runtime would be to generate a huge amount of entities (i.e. thousands) in the data stage and die/spawning them in as required. As the only other still writeable alternatives of power_production/consumption would completely mess up the power statistics (unless it's possible to make EEI buffers not be counted into the networks total accumulator capacity... should i write a request for that?)

TL;DR:
Bleh. Headache.

PS:
@OP: In a purely comsumption situation (if that is your case) you might actually be able to spawn the EEI with a full energy buffer and then use power_consumption for the desired effect.
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.
thesixthroc
Inserter
Inserter
Posts: 29
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

.electric_input_flow_limit read/write?

Post by thesixthroc »

I run a multiplayer scenario (softmod) in which it would be convenient to modify this value for LuaEntity. I notice in the past, in 0.15, it was writable.

Is this something easy to make writable again, or does that have complications?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2980
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: .electric_input_flow_limit read/write?

Post by boskid »

I have no idea what you are talking about 0.15. There was a note saying it was only writable for ElectricEnergyInterface. Right now to change ElectricEnergyInterface paramters there are power_production and power_usage. Main limitation for making it writable for all entities is that it is not part of the entity state but the value on read comes directly from the energy source prototype which can only be changed in data stage.
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making entity electric flow fields writable

Post by Bilka »

Merged with an older topic.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
thesixthroc
Inserter
Inserter
Posts: 29
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Re: Making entity electric flow fields writable

Post by thesixthroc »

Thanks for the reply.

My scenario runs scripts based on charge delivered to a rocket silo, but even with installing 4x Prod 3 modules, and removing all energy from the silo energy bugger every tick, the fixed electric_input_flow_limit means it can still only draw a maximum of 18MW.

It's a bit difficult to place other entities for players to charge in a way that makes sense. I think doing this via accumulators/EEIs doesn't work too well, because (last time I checked was over a year ago), accumulators have low priority in the network and it's inconvenient in my scenario for them to be powered last over everything else.

If there aren't any simple things I'm missing, I'll either wait for more modding interface, or try to think how to rework the 'charge point' to include more entities.
Post Reply

Return to “Modding interface requests”