cannot read recipe subgroup from data.raw

Place to get help with not working mods / modding interface.
scruffyvoltherder
Inserter
Inserter
Posts: 21
Joined: Fri Jun 14, 2024 12:33 am
Contact:

cannot read recipe subgroup from data.raw

Post by scruffyvoltherder »

I'm trying to copy recipes in data-final-fixes.lua, and I need to be able to read the subgroup. None of the recipes in data.raw["recipe"] have the subgroup member present. If I deepcopy a recipe, it still has the original subgroup. I can change the subgroup, but i need to be able to modify the subgroup based on the original name.
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 115
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

Re: cannot read recipe subgroup from data.raw

Post by yaim904 »

I think I can help you, but I don't understand the explanation.

Can you give me a code or before and after data?
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
scruffyvoltherder
Inserter
Inserter
Posts: 21
Joined: Fri Jun 14, 2024 12:33 am
Contact:

Re: cannot read recipe subgroup from data.raw

Post by scruffyvoltherder »

Code: Select all

local function process_recipe(name, recipe)

    if not recipe.results or next(recipe.results) == nil then return end
    if ends_with(name,"_rcomb") then return end


    local new_recipe=table.deepcopy(recipe)
    new_recipe.name=new_recipe.name.."_rcomb"
    new_recipe.hide_from_signal_gui = false
    new_recipe.show_amount_in_title = true
    
    local sg = new_recipe.subgroup
    -- SG is nil here
    
    new_recipe.subgroup="recipe-subgroup"
    --but i can assign it here. 
    
    new_recipe.localised_name=recipe.name

    data.raw.recipe[name.."_rcomb"]=new_recipe
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 115
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

Re: cannot read recipe subgroup from data.raw

Post by yaim904 »

scruffyvoltherder wrote: Fri May 16, 2025 12:48 am
I don't see any error in your code, I think you are missing information.

I suggest changing this line

Code: Select all

    new_recipe.localised_name=recipe.name
To the following line, if you want to assign a name to the object depending on the language and not just the name of the object.

Code: Select all

    new_recipe.localised_name={recipe.name}
Documents

--------------------------------------------------------------------------------------

I think your problem is that you have not created the subgroup.

The following is an example of the code to create a sub-group

Code: Select all

data:extend({
    {
        [ 'type' ] = 'item-subgroup',
        [ 'name' ] = 'recipe-subgroup',
        [ 'group' ] = 'logistics',
        [ 'order' ] = 'a'
    }
})
Recipes can be linked to a subgroup, but the subgroup must be created. The order property will give you the position in which it will appear. Also, note that each subgroup must belong to a group (or you can create your own).

The following is an example of the code of a group

Code: Select all

{
    [ 'type' ] = 'item-group',
    [ 'name' ] = 'logistics',
    [ 'order' ] = 'a',
    [ 'icon' ] = '__base__/graphics/item-group/logistics.png',
    [ 'icon_size' ] = 128
}
This information can be found at

Code: Select all

data.raw["item-group"]
data.raw["item-subgroup"]
13 - copia.png
13 - copia.png (202.35 KiB) Viewed 178 times
--------------------------------------------------------------------------------------
I hope I've been helpful, and if not, I'll look forward to hearing from you.
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
Post Reply

Return to “Modding help”