Page 1 of 1

[0.17.68] Some equipment prototype energy sources report incorrect buffer_capacity

Posted: Thu Sep 12, 2019 1:20 pm
by eradicator
What?
Fusion reactor and exoskeleton report different sizes for buffer_capacity and max_energy. Noticibly these are the only two prototypes that have buffer_capacity 0 in base game.

Details

Data (optional):

Code: Select all

for k,v in pairs(data.raw) do if k:match'equipment$' then for _,y in pairs(v) do
  y.energy_source.buffer_capacity = "1TJ"
  end end end
Control:

Code: Select all

/c
for k,v in pairs(game.player.get_inventory(defines.inventory.character_armor)[1].grid.equipment) do 
  print(v.name,v.prototype.energy_source.buffer_capacity,v.max_energy)
  end
Result (Vanilla):

Code: Select all

fusion-reactor-equipment        0       12500
energy-shield-equipment 120000  120000
energy-shield-mk2-equipment     180000  180000
battery-equipment       20000000        20000000
exoskeleton-equipment   0       33333.333333333
personal-roboport-equipment     35000000        35000000
personal-roboport-mk2-equipment 35000000        35000000
night-vision-equipment  120000  120000
battery-mk2-equipment   100000000       100000000
Result (1TJ Buffer):

Code: Select all

fusion-reactor-equipment        1000000000000   12500
energy-shield-equipment 1000000000000   1000000000000
energy-shield-mk2-equipment     1000000000000   1000000000000
battery-equipment       1000000000000   1000000000000
exoskeleton-equipment   1000000000000   33333.333333333
personal-roboport-equipment     1000000000000   1000000000000
personal-roboport-mk2-equipment 1000000000000   1000000000000
night-vision-equipment  1000000000000   1000000000000
battery-mk2-equipment   1000000000000   1000000000000
Expected Result
buffer_capacity and max_energy should always be equivalent, preferably by supporting buffer_size override on the last two equipment types.

Re: [0.17.68] Some equipment prototype energy sources report incorrect buffer_capacity

Posted: Thu Sep 12, 2019 7:27 pm
by Rseding91
Thanks for the report however that's working correctly.

The buffer_capacity for both of those are dynamically set at equipment creation time based off the values of the given equipment.

For generators it's the power they produce per tick. For exo-skeletons it's the energy consumption * 10.

Re: [0.17.68] Some equipment prototype energy sources report incorrect buffer_capacity

Posted: Thu Sep 12, 2019 7:30 pm
by eradicator
Rseding91 wrote: Thu Sep 12, 2019 7:27 pm Thanks for the report however that's working correctly.

The buffer_capacity for both of those are dynamically set at equipment creation time based off the values of the given equipment.

For generators it's the power they produce per tick. For exo-skeletons it's the energy consumption * 10.
Can't their respective energy_source prototypes be at least made to report that same value? As it stands anybody who doesn't know this quirk and relies on the prototype data (instead of max_energy) will get the wrong numbers.

I'm not saying that the dynamic consumption is a bug. I'm saying that the two numbers are different is a bug.

Re: [0.17.68] Some equipment prototype energy sources report incorrect buffer_capacity

Posted: Thu Sep 12, 2019 8:03 pm
by Rseding91
I don't consider it worth making them do that. Most entities use the same runtime dynamic buffer size based off their maximum energy demands. For example: assembling machines need more power if you speed module them and so their buffer size changes when under the effects of speed modules. That's impossible to reflect through the prototype alone.

Making equipment do that just because it is possible won't help the overall situation and just serve as another point of confusion. buffer_size in an entities energy source prototype definition should be default ignored until it's shown that it's directly used by the entity. For example: accumulators, and laser turrets.

In most cases it's meaningless.

Re: [0.17.68] Some equipment prototype energy sources report incorrect buffer_capacity

Posted: Thu Sep 12, 2019 8:22 pm
by eradicator
Rseding91 wrote: Thu Sep 12, 2019 8:03 pm buffer_size in an entities energy source prototype definition should be default ignored until it's shown that it's directly used by the entity. For example: accumulators, and laser turrets.

In most cases it's meaningless.
Hm. How about reflecting that particular bit of information in the API doc then? The page on LuaElectricEnergySourcePrototype is currently almost empty.