Page 1 of 1

[2.0.72] Intermediate products are not working

Posted: Wed Mar 12, 2025 7:25 pm
by yaim904
I have version 2.0.39, here is the code I'm using and the images
I am creating alternative recipes and have created the recipes for the other objects, but only with this one the problem occurs.

Code: Select all

--- --- --- --- --- --- --- --- --- --- --- --- --- ---
---> data.lua
--- --- --- --- --- --- --- --- --- --- --- --- --- ---

local function DeepCopy(value)
    if type(value) ~= "table" then return value end
    local Output = {}
    for Key, Value in pairs(value) do
        Output[Key] = DeepCopy(Value)
    end
    return Output
end

local name = "iron-gear-wheel"
-- local name = "iron-plate"

local item = data.raw.item[name]
item = DeepCopy(item)
item.name = "zzzYAIM904-" .. item.name
item.localised_name = { "", {"item-name." .. name }}

local recipe = data.raw.recipe[name]
recipe = DeepCopy(recipe)
recipe.name = "zzzYAIM904-" .. recipe.name
recipe.localised_name = { "", {"item-name." .. name }}
recipe.category = nil
recipe.ingredients = { {
    type = "item",
    name = item.name,
    amount = 1
} }
recipe.results = { {
    type = "item",
    name = name,
    amount = 1000
} }

data:extend({ item, recipe })

Without the alternative recipe
I have enough iron plates to build conveyor belts and burner inserter.
Captura de pantalla (1).png
Captura de pantalla (1).png (1.11 MiB) Viewed 1761 times
Captura de pantalla (2).png
Captura de pantalla (2).png (1.1 MiB) Viewed 1761 times
With the alternative recipe
inserters what?
Captura de pantalla (3).png
Captura de pantalla (3).png (1.11 MiB) Viewed 1761 times
Captura de pantalla (4).png
Captura de pantalla (4).png (1.11 MiB) Viewed 1761 times
How fixed??
It's a bug??

Re: [2.0.39] How fixed?? It's a bug??

Posted: Wed Mar 12, 2025 8:15 pm
by Muche
It seems the manual crafter has decided to favor your recipe for crafting an iron gear instead of the default one.
As there is no recipe for crafting your gear, an iron gear is not craftable as well.

Adding recipe.allow_as_intermediate = false will skip considering the recipe for manual crafting.

Re: [2.0.39] How fixed?? It's a bug??

Posted: Wed Mar 12, 2025 11:20 pm
by yaim904
This message has been deleted by the author

Re: [2.0.39] How fixed?? It's a bug??

Posted: Thu Mar 13, 2025 1:11 am
by yaim904
Muche wrote: Wed Mar 12, 2025 8:15 pm
Thank you, but that does not solve the problem, it evades it, but does not solve it.

With iron plates it works without any problem.
Captura de pantalla (16).png
Captura de pantalla (16).png (1.02 MiB) Viewed 1665 times

I am looking for everything to work the same way.

The result of the recipe should be included in the other recipes, as seen in the image.

I mean, if you exchange the object for the iron plates and another object, you won't have that problem.
Why?
It's a bug?

Re: [2.0.39] How fixed?? It's a bug??

Posted: Thu Mar 13, 2025 11:14 pm
by yaim904
I think I have made some progress on this issue.

I am now using this code, which works fine with all objects in the game, except iron gears.

This code is NOT FUNCTIONAL, it is only for reference.

Code: Select all

    --- Contenedor de las recetas
    GPrefix.addDataRaw({
        { type = "recipe-category", name = ThisMOD.Prefix .. ThisMOD.Do },
        { type = "recipe-category", name = ThisMOD.Prefix .. ThisMOD.Undo }
    })

    --- Cargar los subgrupos a duplicar
    local Subgroups = {}
    for _, item in pairs(GPrefix.Items) do
        Subgroups[item.subgroup] = {}
    end

    --- Crear los subgrupo de los objetos compactados
    for oldSubgroup, _ in pairs(Subgroups) do
        for i = 1, 2, 1 do
            --- Cambiar el nombre del nuevo subgrupo
            local Name     = i == 1 and ThisMOD.Do or ThisMOD.Undo
            Name           = GPrefix.DeletePrefix(oldSubgroup) .. "-" .. Name
            Name           = ThisMOD.Prefix .. Name
            local Subgroup = GPrefix.DuplicateSubgroup(oldSubgroup, false, Name)
        end
    end

    local Table = {
        "name",
        "subgroup",
        "order",
        "inventory_move_sound",
        "pick_sound",
        "drop_sound",
        "localised_name",
        "localised_description",
        "icons"
    }

    -- table.insert(ThisMOD.AvoidItem, "iron-gear-wheel")

    for name, item in pairs(GPrefix.Items) do
        if GPrefix.getKey(item.flags, "not-stackable") then goto JumpItem end
        if GPrefix.getKey(ThisMOD.AvoidType, item.type) then goto JumpItem end
        if GPrefix.getKey(ThisMOD.AvoidItem, item.name) then goto JumpItem end
        if string.find(name, "zzzYAIM904") then return end





        local Item = {}
        for _, key in pairs(Table) do
            Item[key] = GPrefix.DeepCopy(item[key])
        end

        Item.name       = "zzzYAIM904-" .. Item.name
        Item.type       = "item"
        Item.stack_size = ThisMOD.StackSize
        Item.subgroup   = ThisMOD.Prefix .. GPrefix.DeletePrefix(Item.subgroup) .. "-" .. ThisMOD.Do

        table.insert(Item.icons, 1, ThisMOD.Graphics.Background)





        local URecipe               = {}
        URecipe.type                = "recipe"
        URecipe.name                = "zzzYAIM904-u-" .. name
        URecipe.localised_name      = GPrefix.DeepCopy(Item.localised_name)
        URecipe.icons               = GPrefix.DeepCopy(item.icons)
        URecipe.category            = ThisMOD.Prefix .. ThisMOD.Undo
        URecipe.allow_decomposition = false
        URecipe.ingredients         = { { type = "item", name = Item.name, amount = 1 } }
        URecipe.results             = { { type = "item", name = name, amount = ThisMOD.Ingredients } }
        URecipe.subgroup            = ThisMOD.Prefix .. GPrefix.DeletePrefix(item.subgroup) .. "-" .. ThisMOD.Undo

        table.insert(URecipe.icons, ThisMOD.Graphics.ArrowU)





        local DRecipe                 = {}
        DRecipe.type                  = "recipe"
        DRecipe.name                  = "zzzYAIM904-" .. name
        DRecipe.localised_name        = GPrefix.DeepCopy(Item.localised_name)
        DRecipe.icons                 = GPrefix.DeepCopy(item.icons)
        DRecipe.category              = ThisMOD.Prefix .. ThisMOD.Do
        DRecipe.allow_decomposition   = false
        DRecipe.allow_as_intermediate = false
        DRecipe.results               = { { type = "item", name = Item.name, amount = 1 } }
        DRecipe.ingredients           = { { type = "item", name = name, amount = ThisMOD.Ingredients } }
        DRecipe.subgroup              = ThisMOD.Prefix .. GPrefix.DeletePrefix(item.subgroup) .. "-" .. ThisMOD.Do

        table.insert(DRecipe.icons, ThisMOD.Graphics.ArrowD)





        GPrefix.addDataRaw({ Item, DRecipe, URecipe })





        GPrefix.addRecipeToTechnology(item.name, URecipe)
        GPrefix.addRecipeToTechnology(item.name, DRecipe)





        :: JumpItem ::
    end

    --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    ---> Permirte la descompresión sin la maquina
    --- --- --- --- --- --- --- --- --- --- --- --- --- ---

    table.insert(data.raw["character"].character.crafting_categories, ThisMOD.Prefix .. ThisMOD.Undo)
    table.insert(data.raw["god-controller"].default.crafting_categories, ThisMOD.Prefix .. ThisMOD.Undo)
And it generated a doubt, how do I add a crafting category to the recipes that players can create with their hands?

I tried with this line, but it doesn't work.

Code: Select all

table.insert(data.raw["character"].character.crafting_categories, ThisMOD.Prefix .. ThisMOD.Undo)
03-13-2025, 18-14-03.png
03-13-2025, 18-14-03.png (726.95 KiB) Viewed 1598 times

Re: [2.0.39] How fixed?? It's a bug??

Posted: Fri Mar 14, 2025 12:25 am
by yaim904
Update
This is the simplified and FUNCTIONAL example code, it still has the error, and I still don't know why it doesn't work not with the gears but with the other objects.

Code: Select all

    --- --- --- --- --- --- --- --- --- --- --- --- --- ---
    ---> data.lua
    --- --- --- --- --- --- --- --- --- --- --- --- --- ---

    local function DeepCopy(value)
        if type(value) ~= "table" then return value end
        local Output = {}
        for Key, Value in pairs(value) do
            Output[Key] = DeepCopy(Value)
        end
        return Output
    end

    -- local name = "iron-gear-wheel"
    local name = "iron-plate"

    local Item = data.raw.item[name]
    Item = DeepCopy(Item)
    Item.name = "zzzYAIM904-" .. Item.name
    Item.localised_name = { "", "YAIM904 ", { "item-name." .. name } }

    local URecipe = data.raw.recipe[name]
    URecipe = DeepCopy(URecipe)
    URecipe.name = "zzzYAIM904-u-" .. URecipe.name
    URecipe.localised_name = { "", { "item-name." .. name } }
    URecipe.category = nil
    URecipe.ingredients = { {
        type = "item",
        name = Item.name,
        amount = 1
    } }
    URecipe.results = { {
        type = "item",
        name = name,
        amount = 1000
    } }

    local DRecipe = data.raw.recipe[name]
    DRecipe = DeepCopy(DRecipe)
    DRecipe.name = "zzzYAIM904-" .. DRecipe.name
    DRecipe.localised_name = { "", "YAIM904 ", { "item-name." .. name } }
    DRecipe.category = nil
    DRecipe.results = { {
        type = "item",
        name = Item.name,
        amount = 1
    } }
    DRecipe.ingredients = { {
        type = "item",
        name = name,
        amount = 1000
    } }

    data:extend({ Item, DRecipe, URecipe })

With iron plates
03-13-2025, 18-58-34.png
03-13-2025, 18-58-34.png (1023.46 KiB) Viewed 1582 times
03-13-2025, 18-58-42.png
03-13-2025, 18-58-42.png (1019.37 KiB) Viewed 1582 times
03-13-2025, 19-04-27.png
03-13-2025, 19-04-27.png (1 MiB) Viewed 1582 times
With iron gear wheel
03-13-2025, 19-00-16.png
03-13-2025, 19-00-16.png (1013.77 KiB) Viewed 1582 times
03-13-2025, 19-00-25.png
03-13-2025, 19-00-25.png (1.03 MiB) Viewed 1582 times
03-13-2025, 19-02-52.png
03-13-2025, 19-02-52.png (1.01 MiB) Viewed 1582 times
Description
Try the code, and see for yourself.
When using gears, you cannot create transport belts and incertators.
When using any other item, no problem.
How fixed??
It's a bug??
Maybe I'm not making myself clear, but I'm willing to answer as many questions as it takes to arrive at a solution.

Re: [Solved][[2.0.39] How fixed?? It's a bug??

Posted: Wed Apr 16, 2025 3:02 pm
by yaim904
I didn't hear that this was resolved.
I just checked and it is now working.
Thank you.

Re: [2.0.39] How fixed?? It's a bug??

Posted: Tue Oct 14, 2025 10:23 pm
by yaim904
Hello, it's me again.
Yesterday I was updating the MOD that uses this code, and I was surprised to find that it doesn't work.

After carefully reviewing it, I found the reason.
It works with only iron plates: Yes
(52).png
(52).png (842.55 KiB) Viewed 779 times
(53).png
(53).png (852.65 KiB) Viewed 779 times
It works with only iron gears: Yes
(49).png
(49).png (839.95 KiB) Viewed 779 times
(50).png
(50).png (828.66 KiB) Viewed 779 times
It works with both active: No
(54).png
(54).png (762.41 KiB) Viewed 779 times
(55).png
(55).png (747.98 KiB) Viewed 779 times
Help
If I'm doing something wrong, please tell me where, why, or how to correct the error.

If it is a bug in the game, please verify that it does not affect other object confines.
I'm attaching functional test code.

Code: Select all

--- --- --- --- --- --- --- --- --- --- --- --- --- ---
---> data.lua
--- --- --- --- --- --- --- --- --- --- --- --- --- ---

local function DeepCopy(value)
    if type(value) ~= "table" then return value end
    local Output = {}
    for Key, Value in pairs(value) do
        Output[Key] = DeepCopy(Value)
    end
    return Output
end

local function getSignal(signal)
    return data.raw["virtual-signal"]["signal-" .. signal .. ""].icon
end

for _, name in pairs({
    "iron-plate",
    "iron-gear-wheel",
}) do
    local item = data.raw.item[name]

    local Item = DeepCopy(item)
    Item.name = "zzzYAIM904-" .. Item.name
    Item.localised_name = { "", "YAIM904 ", { "item-name." .. name } }
    Item.icons = {
        { icon = getSignal("pink") },
        {
            icon = item.icon,
            icon_size = item.icon_size
        }
    }

    local URecipe = {}
    URecipe.type = "recipe"
    URecipe.name = "zzzYAIM904-u-" .. item.name
    URecipe.localised_name = { "", { "item-name." .. name } }
    URecipe.ingredients = { {
        type = "item",
        name = Item.name,
        amount = 1
    } }
    URecipe.results = { {
        type = "item",
        name = name,
        amount = 1000
    } }
    URecipe.icons = {
        { icon = getSignal("green") },
        {
            icon = item.icon,
            icon_size = item.icon_size
        }
    }

    local DRecipe = {}
    DRecipe.type = "recipe"
    DRecipe.name = "zzzYAIM904-d-" .. item.name
    DRecipe.localised_name = { "", "YAIM904 ", { "item-name." .. name } }
    DRecipe.results = { {
        type = "item",
        name = Item.name,
        amount = 1
    } }
    DRecipe.ingredients = { {
        type = "item",
        name = name,
        amount = 1000
    } }
    DRecipe.icons = {
        { icon = getSignal("red") },
        {
            icon = item.icon,
            icon_size = item.icon_size
        }
    }

    data:extend({ Item, DRecipe, URecipe })
end

Re: [2.0.69] How fixed?? It's a bug??

Posted: Fri Nov 07, 2025 10:03 pm
by yaim904
Hello, it's been almost a month since my last post.

I was hoping to have an answer by now, but I still don't know where the error is or if it's a bug.

Today I downloaded version 2.0.72 and the error is still there.

If I need to create another separate post, I will if no one responds, because I really want an answer.

Re: [2.0.69] How fixed?? It's a bug??

Posted: Sat Nov 08, 2025 12:00 am
by computeraddict
yaim904 wrote: Fri Nov 07, 2025 10:03 pm Hello, it's been almost a month since my last post.
It is still unclear what the problem is from reading the English.

Re: [2.0.69] How fixed?? It's a bug??

Posted: Sat Nov 08, 2025 12:50 am
by Loewchen
It would help if you would describe what you expect the code to do and what it does instead. It might also be easier to understand if you used a translator.

Re: [2.0.69] How fixed?? It's a bug??

Posted: Sat Nov 08, 2025 1:31 am
by yaim904
computeraddict wrote: Sat Nov 08, 2025 12:00 am
Thank you for the observation. English is not my native language.


Loewchen wrote: Sat Nov 08, 2025 12:50 am
I have created alternative recipes to create the items, but for some reason the intermediate products are not working.

I am attaching photographic evidence and test code showing the problem.

Note the number of transport belts that can be crafted.
yaim904 wrote: Tue Oct 14, 2025 10:23 pm
If I am not making myself clear, please ask.

Re: [2.0.72] Intermediate products are not working

Posted: Wed Nov 19, 2025 9:11 pm
by yaim904
I suppose the translator, my English, and my explanation are so poor that the problem is unclear.
I prefer to believe that, rather than have no one from Wube or the members of this forum see this and think that everything is fine.