Page 1 of 1

[Rseding91] [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Thu Feb 11, 2021 6:08 pm
by Xorimuth
As used in https://lua-api.factorio.com/latest/Lua ... flow_count, it actually returns the average value over 5 seconds, not 1. I've only tested this with electrical networks.

For my mod, I want this time period to be as low as possible. Having an actual '1 second' option would be good, although 1 tick would be much better! (Or you could expose the total value over 1 tick, which would be perfect! viewtopic.php?f=28&t=94959)

If need be, I can provide a mod and save that demonstrates this.

Re: [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Thu Feb 11, 2021 6:23 pm
by Xorimuth
In case you're concerned about any backwards incompatible changes you fancy making, the string 'defines.flow_precision_index.one_second' only occurs in the following mods:

capacity-combinator_1.0.3 capacity-combinator_1.0.3/control.lua
power-combinator_4.3.3 power-combinator_4.3.3/control.lua (same author as capacity-combinator)
spawner-alert_0.1.7 spawner-alert_0.1.7/control.lua
PowerOverload_1.0.0 PowerOverload_1.0.0/control.lua (my mod)

Re: [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Thu Feb 11, 2021 6:41 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.

The defines are correct but the logic in get_flow_count was wrong.

Re: [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Thu Feb 11, 2021 7:39 pm
by Rseding91
I did notice that the one-second window will give numbers back scaled to 1 minute. Is that what you meant?

It matches how the GUI functions; it takes the 1 second window and says "if you did this for a minute; here's what you would make".

Re: [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Thu Feb 11, 2021 8:13 pm
by Xorimuth
Rseding91 wrote: Thu Feb 11, 2021 7:39 pm I did notice that the one-second window will give numbers back scaled to 1 minute. Is that what you meant?

It matches how the GUI functions; it takes the 1 second window and says "if you did this for a minute; here's what you would make".
That bit is fine, I just multiply the result by 60 to get it in watts. Its nice in that you can pick any of the defines and your maths would be the same, the only difference being how far back in time it effects the result.

Screenshot 2021-02-11 at 20.07.20.png
Screenshot 2021-02-11 at 20.07.20.png (5.48 KiB) Viewed 3214 times
What I'm really wanting (but is outside the scope of this bug report) is a way to get the network consumption (506MW in this screenshot), which compared to my current solution:
1. would require no calculations on the lua side (this code is ran many times every tick)
2. would update instantly (not be averaged over the last second)

2. could also be achieved by adding a defines.flow_precision_index.one_tick

Anyway, this has spilled over from viewtopic.php?f=28&t=94959, where it should belong.

Re: [Rseding91] [1.1.21] defines.flow_precision_index.one_second actually represents 5 seconds

Posted: Tue Feb 16, 2021 1:44 pm
by Xorimuth
Hmm, I'm pretty sure that this has still not been fixed as of 1.1.24. With the mods Power Overload and Editor Extensions, the following blueprint creates a situation where the pole should blow up every second, but it only blows up exactly every 5 seconds. I'm using `defines.flow_precision_index.one_second`.

Please can this be moved back to "Bug reports", and let me know if I'm misunderstanding something!

Edit: Fixed in 1.1.25: https://wiki.factorio.com/Version_history/1.1.0#1.1.25