The real hierarchy of recipes

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Bong_Cat
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Aug 16, 2023 4:57 pm
Contact:

The real hierarchy of recipes

Post by Bong_Cat »

Hello guys!
I solved my previous problem, but now, even when changing the recipe in data-final-fixes.luca, I don't see any changes in the game, although a note that the recipe has been changed by my mod appears.
Please explain to me, someone, how do I change the recipe 100%?

This piece of code is not working properly:

Code: Select all

data.raw.recipe["stone-furnace"].ingredients = 
{
   {"stone-brick", 5},
    {"alumina", 1}
}

User avatar
Bong_Cat
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Aug 16, 2023 4:57 pm
Contact:

Re: The real hierarchy of recipes

Post by Bong_Cat »

Okey, I find some K2(?) functions and they help me replace recipe of stone-furnace

Code: Select all

krastorio.recipes.overrideIngredients("stone-furnace", {
    {"stone-brick", 5},
    {"alumina", 1}
})
Image

But with tech-cards this function do not work, I don't even see the mark:

Code: Select all

krastorio.recipes.overrideIngredients("logistic-tech-card",{
    {"assembling-machine-1",1},
    {"electronic-circuit", 5},
    {"blank-tech-card", 5}
})
Image
Please help me change these recipes, I think I'm just getting more confused

User avatar
Bong_Cat
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Aug 16, 2023 4:57 pm
Contact:

Re: The real hierarchy of recipes

Post by Bong_Cat »

Okay, in the deep of K2 data I found this:

Code: Select all

-- Add a new recipe variation for one mod
-- (call this function two time with the same mod_name, science_pack_name will overwrite the previus variation)
-- this function must be called with the same argument in setting-update stage and in data-update stage, both!
-- @ mod_name, name of mod that use this recipe for this science pack
-- @ science_pack_name, name of science pack es: "automation-science-pack"
-- @ recipe, all recipe defined as standard of data.raw of Factorio
function krastorio.science_pack_recipes.addRecipeVariation(mod_name, science_pack_name, recipe)
  if not krastorio.science_pack_recipes[mod_name] then
    krastorio.science_pack_recipes[mod_name] = {}
  end
  if data.raw["string-setting"] and data.raw["string-setting"]["kr-" .. science_pack_name .. "-recipe"] then
    table.insert(data.raw["string-setting"]["kr-" .. science_pack_name .. "-recipe"].allowed_values, mod_name)
  else
    krastorio.science_pack_recipes[mod_name][science_pack_name] = recipe
  end
end

return krastorio.science_pack_recipes
I did as it says here:

Code: Select all

--Смена Рецепта Автоматизационной(Красной) научной карты

krastorio.science_pack_recipes.addRecipeVariation("ArtHous's Tweaks", "automation-science-pack", {
    type = "recipe",
    name = "automation-science-pack",
    enabled = false,
    energy_required = 20,
    result_count = 5,
    ingredients = {
      { "blank-tech-card", 5},
      { "kr-loader", 1}
    },
    result = "automation-science-pack"
})

--Смена Рецета Логистической(Залёной) научной карты

krastorio.science_pack_recipes.addRecipeVariation("ArtHous's Tweaks", "logistic-science-pack", {
    type = "recipe",
    name = "logistic-science-pack",
    enabled = false,
    energy_required = 20,
    result_count = 5,
    ingredients = {
      { "blank-tech-card", 5},
      { "electronic-circuit", 5},
      { "assembling-machine-1", 1}
    },
    result = "logistic-science-pack"
})
but it doesn't work.
Can someone explain to me what's wrong?

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1604
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: The real hierarchy of recipes

Post by jodokus31 »

If you simply want to override some recipes of K2, you probably should do in the data-updates state and/or let your mod depend on K2
If you call factorio with the --dump-data flag, you get an output file of the structure of actual existing recipes, etc. (f.e. if a recipe uses normal/expensive or not)

Based on that, it should be straightforward to adjust the recipes with lua

If you rather want to dig into K2 and use those tool functions, you should exactly check, what they do. They can make things easier, if you know what they do. I have no clue about K2

Post Reply

Return to “Modding help”