Page 1 of 1

"terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 5:24 pm
by luc
1) It's tertiary, not terciary.

2) It seems nicer to have a numeric (int or float) usage_priority, rather than strings. The strings "primary-input", "secondary-input" and "terciary" are 2a) inconsistent, 2b) overly long where "primary", "secondary" and "tertiary" makes perfect sense (it seems it actually was like this in the past, but it was changed for no apparent reason?) and 2c) it doesn't scale.

3) Objects with "terciary" usage_priority are super weird. The game seems to think it's an accumulator... but also not. In my test environment, there is no steam at all. Only solar panels and regular accumulators. I have a custom entity with energy_source={type=electric, usage_priority=terciary}. I observe:

3a) If "buffer_capacity" is not given (in electric_source) and energy_usage is very large (test case: 9PW), the game seems to assume it has an infinite buffer. In the electric overview screen (when you click a power pole), the "accumulator charge" bar is completely empty, while showing a value like "104GJ" (if my accumulators have 37GJ). It keeps filling this non-existent buffer with power before filling the other accumulators' buffer.

3b) If "buffer_capacity" is not given (in electric_source) and energy_usage is very large (test case: 9PW), the game seems to assume the buffer is infinitely full. It will draw from this buffer before drawing from real accumulators (even though electric output flow is not given, just like in a roboport, which also does not deliver back to the network). The other accumulators' capacity is 37GJ. In the electric overview screen (when you click a power pole), the "accumulator charge" bar shows something like 37.5GJ when it gets night. Early in the night, 0.5GJ is used up and the accumulator charge now shows 37GJ. This means all accumulators are full, except the custom entity, which must now be empty. Still, the accumulators do not turn on and the factory says it has plenty of power, even though none is produced. 119MW which comes from nowhere. See screenshot [1].

3c) If "buffer_capacity" is 0J and energy_usage is smaller (test case: 9MW), the game will pump an infinite amount of electricity into it. While it is getting day, I place this custom entity. The solar panels work at peak performance (producing 496MW) and the factory needs much less, only about 120MW, but the accumulators immediately stop charging. See screenshot [2]. If I remove the custom entity, the accumulators will start charging again (not shown in screenshot).

Screenshot [1]: https://snag.gy/s56lIi.jpg

Screenshot [2]: https://snag.gy/SqbWzx.jpg

---

What I am trying to do, is make an object that can use an almost infinite amount of power. In order to not drain the factory during the night, it needs to have "terciary" priority (if it's primary or secondary, it will try to draw before the accumulators, which means the accumulators will be permanently empty). I'd actually like to give it quaternary priority but that string is undefined ("Error, invalid electric usage priority: quaternary"). It seems nicer if the priority is just a float, so people can have something like priority 2.5 (before accumulators, below everything else) or 4 (after everything else). Using "terciary" priority, the object currently behaves super weird so I'm not sure it's possible to make this mod with the current API :(

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 5:29 pm
by Rseding91
Priorities are fixed values associated with a specific order and way energy is transferred in the C++ code. Making it a float is never going to happen. Additionally the "terciary" type was created exclusively for accumulators - anything using it will act like an accumulator. If that's not the behavior you want then don't use it.

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 5:49 pm
by luc
Is there any way I can let something draw an infinite amount of power with a lower priority than (or equivalent to) accumulators?

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 6:03 pm
by Rseding91
luc wrote:Is there any way I can let something draw an infinite amount of power with a lower priority than (or equivalent to) accumulators?
No.

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 6:07 pm
by luc
Well, I guess thanks for the clear, quick and concise replies.

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 7:09 pm
by Supercheese
Can we at least fix the spelling, though? ;)

Re: "terciary" power usage_priority is acting weird

Posted: Sun Apr 02, 2017 7:24 pm
by luc
Supercheese wrote:Can we at least fix the spelling, though? ;)
Nope, it's hardcoded in the C++ code and therefore it cannot even be considered. Rseding just said so ;) :P

Re: "terciary" power usage_priority is acting weird

Posted: Mon Apr 03, 2017 9:08 pm
by Supercheese
luc wrote:Nope, it's hardcoded in the C++ code and therefore it cannot even be considered. Rseding just said so ;) :P
Well, Rseding himself can fix it, of course -- that was what I meant.

Re: "terciary" power usage_priority is acting weird

Posted: Wed Apr 05, 2017 12:44 pm
by bobingabout
We have seen other spelling fixes, usually at major version increases, like, I dunno, 0.12-0.13.
Wait, aren't we expecting that to happen shortly? I vote fix it.

Re: "terciary" power usage_priority is acting weird

Posted: Thu Apr 06, 2017 6:32 pm
by luc
Supercheese wrote:
luc wrote:Nope, it's hardcoded in the C++ code and therefore it cannot even be considered. Rseding just said so ;) :P
Well, Rseding himself can fix it, of course -- that was what I meant.
Yeah, just like checking whether object has a buffer and output flow rate -> then it's an accumulator (rather than going "oh low prio, let the game assume it's an accumulator even though it has no output and no buffer").