scruffyvoltherder wrote: Wed Jun 11, 2025 1:39 am
for example, if the original recipe had the "circuit-network" subgroup, i want the copied recipe to have the subgroup "circuit-network-rcomb". all of the rcomb recipes are going to sit in their own tab.
If you really want to create a new tab (next to the vanilla tabs "Logistics", "Production", "Intermediate products", "Combat"), you don't need an
ItemSubGroup, but an
ItemGroup. Subgroups are the rows within a tab.
ItemGroup::order determines the position of your tab. ItemSubGroup::order determines the order within a tab (affects the row where the recipe will be listed).
RecipePrototype::order affects the order of recipes within a row.
To create a new tab, you must create a new group:
Code: Select all
data:extend({
{
type = "item-group",
name = "my-new-group",
icons = { }, -- Insert your icon for the tab here!
localised_name = {"item-group-name.my-new-group"}, -- Add to locale file!
localised_description = {"item-group-description.my-new-group"},
order = "zzzz" -- Add new tab towards the end
}
})
An ItemSubGroup is always associated with a certain group, so you must create your own subgroup:
Code: Select all
data:extend({
-- Create as many subgroups as you need!
{
type = "item-subgroup",
name = "my-subgroup-a",
group = "my-new-group", -- Must be the same for all subgroups in the same tab!
order = "order string" -- Lexical order of string determines row within this tab
}
})
Now you can move your recipes to a new tab by assigning them to a subgroup.
As you've already noticed, RecipePrototype::subgroup may not be set. Notably, this is true for vanilla recipes:

- recipe-definition.png (299.47 KiB) Viewed 338 times
(You can open the prototype GUI by hovering the cursor over a recipe icon and using the key combination set in "Settings --> Controls --> Debug --> Open prototype explorer GUI".)
What to do in this case? Well, there already is a hint: the prototype for subgroups is called
"ItemSubGroup", not "RecipeSubGroup"! So if you have a recipe that doesn't define a subgroup, its subgroup will be derived from whatever is produced by the recipe (see
RecipePrototype::results). If a recipe has >1 results, the subgroup will be derived from what is set as
RecipePrototype::main_product.
So to determine the subgroup of a recipe, you should:
- Use recipe.subgroup, if available. This will be set if the recipe produces nothing!
- No subgroup yet?
- recipe.main_product is set (name of an item or a fluid):
Code: Select all
local result = data.raw.item[recipe.main_product] or data.raw.fluid[recipe.main_product]
local use_group = result.subgroup
- recipe.results is set: use subgroup of first result
Code: Select all
local result = recipe.results[1]
local use_group = data.raw[result.type][result.name].subgroup