Incorrect Energy Source types are confusingly errored when only Electric is valid

User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 120
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by PennyJim »

There's a number of prototypes that expect only an ElectricEnergySource, which is fine. My problem is that the error messages will complain about missing usage_priority before it'll mention that the type is incorrect.

The golden solution would be to complain that the incorrect type of EnergySource was given (like it does when it takes in Electric or Void).
A lesser but still completely valid solution, is to check the `type` matches the expected energy source at the beginning of their respective validation functions (assuming things about internal structure); Getting the same behavior of when the given EnergySource is also a valid ElectricEnergySource (minus the type).


In short, I just wish there was a slightly different 'error priority' and that this code would complain about it being a burner source instead of missing the usage_priority (which is confusing when you have an incorrect assumption).

Code: Select all

-- Get the energy source of some prototype
-- Here's a handful of simple examples (I did not extensively test every only electric prototype)
local energy_source = data.raw["lightning-attractor"]["lightning-rod"].energy_source
-- local energy_source = data.raw["accumulator"]["accumulator"].energy_source
-- local energy_source = data.raw["electric-energy-interface"]["hidden-electric-energy-interface"].energy_source

-- Here's an Electric or Void to showcase the behavior that I want replicated
-- local energy_source = data.raw["beacon"]["beacon"].energy_source

-- Make ElectricEnergySource invalid
-- Comment this out to see the 'lesser' fix
energy_source.usage_priority = nil

-- Convert to valid HeatEnergySource
energy_source.type = "burner"
energy_source.fuel_inventory_size = 1
Last edited by PennyJim on Thu Jan 16, 2025 11:51 pm, edited 1 time in total.
protocol_1903
Fast Inserter
Fast Inserter
Posts: 224
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by protocol_1903 »

+1
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
curiosity
Filter Inserter
Filter Inserter
Posts: 651
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by curiosity »

This belongs in bug reports.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 120
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Re: Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by PennyJim »

curiosity wrote: Fri Jan 17, 2025 12:51 am This belongs in bug reports.
Maybe it does, but I put it here since the overall behavior is fine, it's just *how* it errors can be confusing.
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 323
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by Therenas »

I really think this should be fixed in the code instead of documenting confusing behavior. Moved to interface requests.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3925
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Incorrect Energy Source types are confusingly errored when only Electric is valid

Post by boskid »

Ok, for 2.0.52 i made the type check to happen before loading rest of energy source data.

Code: Select all

   3.245 Error ModManager.cpp:1758: Error while loading entity prototype "lightning-rod" (lightning-attractor): This prototype can only use electric energy source.
Post Reply

Return to “Implemented mod requests”