EquipmentPrototype states energy_source as ElectricEnergySource but it can be different - No, just confusing

Post Reply
Soul-Burn
Inserter
Inserter
Posts: 28
Joined: Sun Jan 31, 2021 9:07 pm
Contact:

EquipmentPrototype states energy_source as ElectricEnergySource but it can be different - No, just confusing

Post by Soul-Burn »

The EquipmentPrototype page shows energy_source specifically as ElectricEnergySource rather than a generic EnergySource.

Some mods, e.g. Jetpack successfully use a battery equipment with an energy_source of type = "void".

There are many other places where energy_source is set to specific sources. Worth looking over those as well.

Bilka
Factorio Staff
Factorio Staff
Posts: 3157
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: EquipmentPrototype states energy_source as ElectricEnergySource but it can be different

Post by Bilka »

It's getting loaded as an electric energy source. When the energy source is directly loaded as one of the subtypes (NOT via EnergySource or another union type), the "type" is ignored, regardless of whether it is correct or incorrect.

I'll consider this post an indication to improve https://lua-api.factorio.com/latest/typ ... .html#type to mention that not only it's not mandatory, is completely ignored when the energy source is loaded directly as a ElectricEnergySource.

See also viewtopic.php?p=595871#p595871.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2252
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: EquipmentPrototype states energy_source as ElectricEnergySource but it can be different - No, just confusing

Post by boskid »

Jetpack creates equipment specifying `energy_source.type = "void"` but game ignores this field as it is implemented to only ever load electric energy source (there is no need to specify type if there is nothing to choose from). This is why jetpack also specifies `usage_priority` as otherwise the electric energy source would not load. You can verify that jetpack has electric energy source by opening Prototype Explorer GUI (Ctrl+Shift+E) and in equipment search for jetpack: energy source prototype is marked as type `unique_ptr<ElectricEnergySourcePrototype>`, it literally does not accept any other energy source type.

Bilka
Factorio Staff
Factorio Staff
Posts: 3157
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: EquipmentPrototype states energy_source as ElectricEnergySource but it can be different - No, just confusing

Post by Bilka »

Bilka wrote:
Tue Nov 21, 2023 8:40 pm
I'll consider this post an indication to improve https://lua-api.factorio.com/latest/typ ... .html#type to mention that not only it's not mandatory, is completely ignored when the energy source is loaded directly as a ElectricEnergySource.
Done for the next version for BurnerEnergySource and ElectricEnergySource.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Resolved Requests”