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