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 2229 times
09-03-2025, 14-03-28.png
09-03-2025, 14-03-28.png (19.87 KiB) Viewed 2229 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.

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

Posted: Tue Nov 11, 2025 8:14 pm
by Quezler
+1, for ocd purposed this is nice, just being able to match the order ingame with the order in the code without messing with overall order strings.

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

Posted: Tue Nov 11, 2025 9:40 pm
by protocol_1903
I'd consider the order in the recipe definition to be the issue in 58757, not how the game displays it.

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

Posted: Mon Jun 29, 2026 3:00 pm
by snouz
Hi, after checking that it's still not possible in 2.1, I am again asking for this feature since the feasibility of it might have changed since 2.0, and because I think the request is still relevant.
06-29-2026, 16-55-27.png
06-29-2026, 16-55-27.png (14.88 KiB) Viewed 327 times
This addition doesn't seem to answer this, as this is only controlling the order of item groups, but doesn't affect e.g. coal compared to iron.

I would argue the that it would need to be declared in the prototype instead of the item itself, as you might have a recipe that requires 10000 coal and 1 iron, and another 10000 iron and 1 coal, so you might want to have the more important one first.

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

Posted: Mon Jun 29, 2026 3:11 pm
by boskid
What is in game right now is enough, you can make game not sort ingredients and sort them manually in data stage however you like using whatever niceness metric you like. What you are asking for is proposing some arbitrary niceness function and requesting for the game to handle it for you, which is rejected. Just sort ingredients on your own if you want.

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

Posted: Mon Jun 29, 2026 3:19 pm
by Rseding91
snouz wrote: Mon Jun 29, 2026 3:00 pm Hi, after checking that it's still not possible in 2.1, I am again asking for this feature since the feasibility of it might have changed since 2.0, and because I think the request is still relevant.

06-29-2026, 16-55-27.png
This addition doesn't seem to answer this, as this is only controlling the order of item groups, but doesn't affect e.g. coal compared to iron.

I would argue the that it would need to be declared in the prototype instead of the item itself, as you might have a recipe that requires 10000 coal and 1 iron, and another 10000 iron and 1 coal, so you might want to have the more important one first.
I think you're missing something. That value does exactly what you're asking for: when false - the ingredients are "what ever they were defined by the lua stage that made them".

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

Posted: Mon Jun 29, 2026 3:55 pm
by snouz
Rseding91 wrote: Mon Jun 29, 2026 3:19 pm
snouz wrote: Mon Jun 29, 2026 3:00 pm Hi, after checking that it's still not possible in 2.1, I am again asking for this feature since the feasibility of it might have changed since 2.0, and because I think the request is still relevant.

06-29-2026, 16-55-27.png
This addition doesn't seem to answer this, as this is only controlling the order of item groups, but doesn't affect e.g. coal compared to iron.

I would argue the that it would need to be declared in the prototype instead of the item itself, as you might have a recipe that requires 10000 coal and 1 iron, and another 10000 iron and 1 coal, so you might want to have the more important one first.
I think you're missing something. That value does exactly what you're asking for: when false - the ingredients are "what ever they were defined by the lua stage that made them".
I had indeed missed that, and I thought I had tested it but I was on the wrong version of my mod. Well thank you for adding this feature, and you can move this to implemented then!
I think to make it clearer, the description for sort_item_ingredients should be:

Default: true
When set to true, item ingredients will be sorted based on ItemGroup::order_in_recipe. When set to false, items are listed in the order in which they're defined in ingredients and products arrays.