Page 1 of 1

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

Posted: Thu Jan 16, 2025 11:42 pm
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

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

Posted: Thu Jan 16, 2025 11:46 pm
by protocol_1903
+1

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

Posted: Fri Jan 17, 2025 12:51 am
by curiosity
This belongs in bug reports.

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

Posted: Fri Jan 17, 2025 12:56 am
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.