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

Place to report issues and suggest improvements to the API documentation.
User avatar
PennyJim
Long Handed Inserter
Long Handed Inserter
Posts: 87
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: 156
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: 559
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
Long Handed Inserter
Long Handed Inserter
Posts: 87
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.
Post Reply

Return to “Documentation Improvement Requests”