EnergySource's type property is not marked optional
- BrainGamer_
- Long Handed Inserter
- Posts: 93
- Joined: Sun Nov 14, 2021 9:52 pm
- Contact:
EnergySource's type property is not marked optional
The type property of a EnergySource like BurnerEnergySource is not marked as an optional and has no further information provided than a static value.
Apparently this is not 100% correct since the type field can be missing if the property that energy source is on allows only a single type of energy source.
Apparently this is not 100% correct since the type field can be missing if the property that energy source is on allows only a single type of energy source.
Re: EnergySource's type property is not marked optional
IMO, it shouldn't allow omission even if unambiguous in certain cases.
- BrainGamer_
- Long Handed Inserter
- Posts: 93
- Joined: Sun Nov 14, 2021 9:52 pm
- Contact:
Re: EnergySource's type property is not marked optional
That is the behavior the current documentation implies at least yeah.
Tho I got my prototype parser to work around it and rather even better since it forced me to handle it in a way that made me better represent the difference between "any" energy source and a specific one being required for a property.
Tho I got my prototype parser to work around it and rather even better since it forced me to handle it in a way that made me better represent the difference between "any" energy source and a specific one being required for a property.
Re: EnergySource's type property is not marked optional
To elaborate, there are two reasons for this:
1. It disrupts the locality of the definition. You have to look at the outer context to see what the default value is.
2. It makes the codebase harder to extend. Imagine some property supports only one type of energy source and type is optional. Mods omit type. Then Wube considers extending that property to support more energy source types. They will either have to break backwards compatibility by making type mandatory or add workarounds to deal with the missing type. This makes the possibility of the support being extended virtually impossible, leading to modders stuck forever with compound entity runtime hacks.
Re: EnergySource's type property is not marked optional
Alternatively, just make the default depend on the entity it's used in and make the type property properly optional in all cases.curiosity wrote: ↑Fri Oct 06, 2023 12:27 pmTo elaborate, there are two reasons for this:
1. It disrupts the locality of the definition. You have to look at the outer context to see what the default value is.
2. It makes the codebase harder to extend. Imagine some property supports only one type of energy source and type is optional. Mods omit type. Then Wube considers extending that property to support more energy source types. They will either have to break backwards compatibility by making type mandatory or add workarounds to deal with the missing type. This makes the possibility of the support being extended virtually impossible, leading to modders stuck forever with compound entity runtime hacks.
Re: EnergySource's type property is not marked optional
So you advocate for raising the entry level to modding? Not that I'm against, but I get the impression that it's not a popular idea.
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: EnergySource's type property is not marked optional
Hmm, I feel as though I'm of the opposite opinion on this. If there's a default depending on the entity, then this means that I now also have to lookup what that is for the entity each time, so not a shortcut.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: EnergySource's type property is not marked optional
I added a note to the docs for the next version and marked the property optional. Only burner and electric energy source have spots where they are the only allowed energy source, so I did not add the note to fluid/void/heat.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.