Context
I'm writing a mod called Induction Charging. This mod allows you to insert Induction Coils into your power armor, which allow you to charge your equipment batteries by standing in range of a power network. It accomplishes this by using an invisible electric-energy-interface at the players position.The total throughput in Watts for the player is determined based on the amount and positioning of the coils in the players power armor. This throughput is only calculated when the grid layout is modified, and stored for use during updates. My mod uses a relatively low update rate to prevent having a noticable UPS impact (once per 15 ticks).
Every update, the shadow entity is updated to see how much energy we received and update the requested energy based on how much we actually need (remaining space in equipment batteries), capped by the throughput we calculated earlier. However, it wasn't before long that I noticed that I was receiving more energy than [tickrate] * [electric_input_flow_limit] per [tickrate] ticks. I've posted about this in the Modding help subforum, but that was before we concluded that this was a bug: viewtopic.php?f=25&t=52451.
Observations
IronCartographer and I have been able to narrow the behaviour down to the following example, after about a week of trying to discern where this behaviour comes from.In the examples below, variables are referred to using square brackets.
Setup
Consider the following power network:
- Solar panels producing 2MW
- Accumulators capable of producing 10MW (storage capacity is irrelevant here, just assume they are always full)
If we add a single electric-energy-interface with:
- [buffer] = 10MW (10x as much as theoretically needed)
- [electric_input_flow_limit] = 1MW / 60
Scenario B
However, this doesn't always hold up. If (continuing from Scenario A) we instead set
- [buffer] = 30MW (still 10x)
- [electric_input_flow_limit] = 3MW / 60 (which exceeds the primary power providers production, thus causing us to also take power from a secondary source)
Expectations
I expect that when I set the [electric_input_flow_limit] field for an electric-energy-interface to (for example) 5000, I receive at most 5000J in one tick.Reproduction
Although the above scenario is quite simple, it is not easy to reproduce by hand. In order to reproduce this behaviour, please download and install the attached attached Test mod. With only the Test mod enabled, please start a new game and wait at least 24 seconds whilst the mod alternates between Scenario A and Scenario B.During this time you are free to move your character. You can click on the power pole to see the current network statistics. The default time before switching scenario is 8 seconds (hence wait 24 seconds for a reasonable sample size), which is chosen so you can easily check the power graph (since 5 seconds is the smallest timeframe) with a reasonable time to spare in order to read the data. Type any message in chat to make a small CSV data dump, saved to /script-output/csv/test.csv.
Additional notes
Additional notes
I hope this post is of use to you! Thanks for the awesome game. I'm looking forward to seeing this issue resolved ![Very Happy :D](./images/smilies/icon_e_biggrin.gif)