Page 1 of 1

Display recipe ingredients and results in the order they're declared in the prototype

Posted: Wed Sep 03, 2025 12:08 pm
by snouz
Hi, even when playing with item order and subgroup, I couldn't get a consistent ordering of items/fluids in recipe tooltips.

The most logical ordering for me would be to prioritize items that are declared the most (for example, if the recipe needs 12 steel and 1 plastic, it'd make sense for the tooltip to display the steel first)

The solution to that, and to avoid any unwanted behavior, I suggest that recipes should keep the recipe/ingredient ordering of the prototype.
Another solution would be to allow for an "order" string in https://lua-api.factorio.com/latest/typ ... otype.html and https://lua-api.factorio.com/latest/typ ... otype.html

example:

Code: Select all

{
    type = "recipe",
    name = "silicon",
    category = "chemistry",
    energy_required = 2,
    ingredients = {
      {type = "item", name = "sand", amount = 5, order = "a"},
      {type = "item", name = "coal", amount = 1, order = "b"},
      {type = "fluid", name = "steam", amount = 10, order = "c"},
    },
    results = {
      {type = "item", name = "silicon", amount = 1, order = "a"}
      {type = "fluid", name = "water", amount = 1, order = "b"}
    },
    allow_productivity = true,
    enabled = false,
  },
(I searched for a similar request and couldn't find one)
09-03-2025, 14-02-44.png
09-03-2025, 14-02-44.png (22.32 KiB) Viewed 303 times
09-03-2025, 14-03-28.png
09-03-2025, 14-03-28.png (19.87 KiB) Viewed 303 times

Re: Display recipe ingredients and results in the order they're declared in the prototype

Posted: Wed Sep 03, 2025 12:22 pm
by curiosity
While not exactly what you want, it's something along a similar line: https://lua-api.factorio.com/latest/pro ... _in_recipe

Re: Display recipe ingredients and results in the order they're declared in the prototype

Posted: Wed Sep 03, 2025 12:23 pm
by boskid
Recipe's item ingredients are sorted since 0.16.31 due to 58757. Ordering is based on ItemGroup's order_in_recipe and if those are equal it uses item order. The only change that could be done is to have a RecipePrototype explicitly opt out of the ingredients sorting, but that would require extra checks to make sure the original issue this sorting fixed is not reintroduced.

Re: Display recipe ingredients and results in the order they're declared in the prototype

Posted: Wed Sep 03, 2025 1:05 pm
by snouz
boskid wrote: Wed Sep 03, 2025 12:23 pm Recipe's item ingredients are sorted since 0.16.31 due to 58757. Ordering is based on ItemGroup's order_in_recipe and if those are equal it uses item order. The only change that could be done is to have a RecipePrototype explicitly opt out of the ingredients sorting, but that would require extra checks to make sure the original issue this sorting fixed is not reintroduced.
My suggestion was to have the ing/result order property overwrite the default behavior, so that if it's not present, it wouldn't change the default behavior.
curiosity wrote: Wed Sep 03, 2025 12:22 pm While not exactly what you want, it's something along a similar line: https://lua-api.factorio.com/latest/pro ... _in_recipe
But order_in_recipe is the ordering of the whole tab's content in recipes, to de-correlate it from the order of the tabs at the top. It doesn't allow any sort of custom ordering in my recipe, just that belts/poles/cars will always be before furnaces/accumulators/modules...

Re: Display recipe ingredients and results in the order they're declared in the prototype

Posted: Wed Sep 03, 2025 7:03 pm
by Osmo
+1, a way of defining custom order for a recipe's ingredients by opting out of auto sorting would be very useful.