Page 1 of 1
Making entity electric flow fields writable
Posted: Wed Dec 13, 2017 5:52 pm
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!
Re: Making entity electric flow fields writable
Posted: Wed Dec 13, 2017 10:37 pm
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.
Re: Making entity electric flow fields writable
Posted: Wed Dec 13, 2017 11:11 pm
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.
Re: Making entity electric flow fields writable
Posted: Thu Dec 14, 2017 8:44 am
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

.
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

.
Re: Making entity electric flow fields writable
Posted: Wed Dec 27, 2017 7:36 pm
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?
Re: Making entity electric flow fields writable
Posted: Wed Dec 27, 2017 8:34 pm
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?
Re: Making entity electric flow fields writable
Posted: Sat Dec 30, 2017 4:39 pm
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
Re: Making entity electric flow fields writable
Posted: Sat Dec 30, 2017 7:21 pm
by Rseding91
Ah thanks, I've fixed them for 0.16.12.
Re: Making entity electric flow fields writable
Posted: Sun Dec 31, 2017 5:18 am
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)?
Re: Making entity electric flow fields writable
Posted: Sun Dec 31, 2017 5:31 am
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.
Re: Making entity electric flow fields writable
Posted: Mon Jan 01, 2018 11:28 am
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.
.electric_input_flow_limit read/write?
Posted: Mon Oct 11, 2021 12:09 pm
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?
Re: .electric_input_flow_limit read/write?
Posted: Mon Oct 11, 2021 12:22 pm
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.
Re: Making entity electric flow fields writable
Posted: Mon Oct 11, 2021 12:29 pm
by Bilka
Merged with an older topic.
Re: Making entity electric flow fields writable
Posted: Mon Oct 11, 2021 1:00 pm
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.