EnergySource's type property is not marked optional

User avatar
BrainGamer_
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Sun Nov 14, 2021 9:52 pm
Contact:

EnergySource's type property is not marked optional

Post by BrainGamer_ »

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.
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by curiosity »

IMO, it shouldn't allow omission even if unambiguous in certain cases.
User avatar
BrainGamer_
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Sun Nov 14, 2021 9:52 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by BrainGamer_ »

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.
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by curiosity »

curiosity wrote: Fri Oct 06, 2023 12:12 pm IMO, it shouldn't allow omission even if unambiguous in certain cases.
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.
braxbro
Inserter
Inserter
Posts: 23
Joined: Sun Jan 01, 2023 2:54 am
Contact:

Re: EnergySource's type property is not marked optional

Post by braxbro »

curiosity wrote: Fri Oct 06, 2023 12:27 pm 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.
Alternatively, just make the default depend on the entity it's used in and make the type property properly optional in all cases.
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by curiosity »

braxbro wrote: Sat Oct 14, 2023 7:25 pm Alternatively, just make the default depend on the entity it's used in and make the type property properly optional in all cases.
See point one.
braxbro
Inserter
Inserter
Posts: 23
Joined: Sun Jan 01, 2023 2:54 am
Contact:

Re: EnergySource's type property is not marked optional

Post by braxbro »

curiosity wrote: Sun Oct 15, 2023 7:51 am See point one.
I don’t think that defaults need to be entirely localized to the structure. Especially if they’re intuitive for those who have worked with the game for awhile (assemblers defaulting to electric, furnaces defaulting to burner, etc.)
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by curiosity »

braxbro wrote: Sun Oct 15, 2023 2:58 pm I don’t think that defaults need to be entirely localized to the structure. Especially if they’re intuitive for those who have worked with the game for awhile (assemblers defaulting to electric, furnaces defaulting to burner, etc.)
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.
braxbro
Inserter
Inserter
Posts: 23
Joined: Sun Jan 01, 2023 2:54 am
Contact:

Re: EnergySource's type property is not marked optional

Post by braxbro »

curiosity wrote: Mon Oct 16, 2023 9:46 am 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.
I think that allowing modders to make shortcuts that are intuitive for those familiar with the game is good.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: EnergySource's type property is not marked optional

Post by FuryoftheStars »

braxbro wrote: Mon Oct 16, 2023 9:55 pm
curiosity wrote: Mon Oct 16, 2023 9:46 am 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.
I think that allowing modders to make shortcuts that are intuitive for those familiar with the game is good.
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
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: EnergySource's type property is not marked optional

Post by Bilka »

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.
Post Reply

Return to “Resolved Requests”