Page 1 of 1

Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 9:28 am
by Darknesspk89
Hey all,

In the last few days I've gotten into Factorio modding, but I've hit a weird issue.
For a test mod I've made a few new modules, including 3 new tiers of the basic ones.
For some odd reason, some of BobsEquipment recipes containing modules like the Fusion Reactor mk2-3-4 and others have some of the modules suddenly switched for my higher tier modules.
Is this a function of BobsEquipment mod that will look for higher tier modules if available, or did I mess anything up?

I checked the code for Bobs, the recipes ask for { "effectivity-module-3", 2 }, { "speed-module-3", 2 ] and { "productivity-module-3", 2 }.
The names of the modules they are 'upgrading' to are called "speed-module-4" to 6, and "productivity-module-4" to 6.

How can I prevent this from happening?

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 10:22 am
by Bilka
How are you making the modules and what else are you modifying?

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 12:17 pm
by Darknesspk89
I'm making the modules as new items in a separate mod I'm making for myself, I've changed nothing in Bobs mods or any others.
They work fine though, I've added the recipes and technologies myself as well.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 12:20 pm
by Bilka
Please share the code, it's very difficult to help based on vague descriptions.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 12:58 pm
by Darknesspk89
mod.cfg

Code: Select all

[item-name]
productivity-module-4=Productivity Module 4
productivity-module-5=Productivity Module 5
productivity-module-6=Productivity Module 6

efficiency-module-4=Efficiency Module 4
efficiency-module-5=Efficiency Module 5
efficiency-module-6=Efficiency Module 6

speed-module-4=Speed Module 4
speed-module-5=Speed Module 5
speed-module-6=Speed Module 6

godule-module-1=Godule 1
godule-module-2=Godule 2
godule-module-3=Godule 3
godule-module-4=Godule 4
godule-module-5=Godule 5
godule-module-6=Godule 6
godule-module-x=Godule X

[technology-name]
productivity-module-4=Productivity Module 4
productivity-module-5=Productivity Module 5
productivity-module-6=Productivity Module 6

efficiency-module-4=Efficiency Module 4
efficiency-module-5=Efficiency Module 5
efficiency-module-6=Efficiency Module 6

speed-module-4=Speed Module 4
speed-module-5=Speed Module 5
speed-module-6=Speed Module 6

godule-module-1=Godule 1
godule-module-2=Godule 2
godule-module-3=Godule 3
godule-module-4=Godule 4
godule-module-5=Godule 5
godule-module-6=Godule 6
godule-module-x=Godule X

[technology-description]
productivity-module-4=Productivity Module 4
productivity-module-5=Productivity Module 5
productivity-module-6=Productivity Module 6

efficiency-module-4=Efficiency Module 4
efficiency-module-5=Efficiency Module 5
efficiency-module-6=Efficiency Module 6

speed-module-4=Speed Module 4
speed-module-5=Speed Module 5
speed-module-6=Speed Module 6

godule-module-1=Godule 1
godule-module-2=Godule 2
godule-module-3=Godule 3
godule-module-4=Godule 4
godule-module-5=Godule 5
godule-module-6=Godule 6
godule-module-x=Godule X
speed-modules.lua

Code: Select all

data:extend{
  {
    type = "module",
    name = "speed-module-4",
    icon = "__MoreModules__/graphics/icons/speed-module-4.png",
    icon_size = 64,
    icon_mipmaps = 4,
    subgroup = "module",
    category = "speed",
    tier = 4,
    order = "c[speed]-d[speed-module-4]",
    stack_size = 50,
    default_request_amount = 10,
    effect = {
      speed = {bonus = 0.8}, -- 80% speed increase
      consumption = {bonus = 0.9} -- 90% energy consumption increase
    },
  },
  {
    type = "module",
    name = "speed-module-5",
    icon = "__MoreModules__/graphics/icons/speed-module-5.png",
    icon_size = 64,
    icon_mipmaps = 4,
    subgroup = "module",
    category = "speed",
    tier = 5,
    order = "c[speed]-e[speed-module-5]",
    stack_size = 50,
    default_request_amount = 10,
    effect = {
      speed = {bonus = 1.2}, -- 120% speed increase
      consumption = {bonus = 1.0} -- 100% energy consumption increase
    },
  },
  {
    type = "module",
    name = "speed-module-6",
    icon = "__MoreModules__/graphics/icons/speed-module-6.png",
    icon_size = 64,
    icon_mipmaps = 4,
    subgroup = "module",
    category = "speed",
    tier = 6,
    order = "c[speed]-e[speed-module-6]",
    stack_size = 50,
    default_request_amount = 10,
    effect = {
      speed = {bonus = 1.6}, -- 160% speed increase
      consumption = {bonus = 1.2} -- 120% energy consumption increase
    },
  }
}

speed-modules-recipes.lua

Code: Select all

data:extend{
  {
    type = "recipe",
    name = "speed-module-4",
    enabled = false,
    ingredients = {
      {"speed-module-3", 10},
      {"advanced-circuit", 10},
      {"processing-unit", 10},
    },
    energy_required = 120,
    result = "speed-module-4"
  },
  {
    type = "recipe",
    name = "speed-module-5",
    enabled = false,
    ingredients = {
      {"speed-module-4", 10}, 
      {"advanced-circuit", 20},
      {"processing-unit", 20},
    },
    energy_required = 240,
    result = "speed-module-5"
  },
  {
    type = "recipe",
    name = "speed-module-6",
    enabled = false,
    ingredients = {
      {"speed-module-5", 20},
      {"advanced-circuit", 40},
      {"processing-unit", 40},
    },
    energy_required = 480,
    result = "speed-module-6"
  }
}
speed-modules-technologies.lua

Code: Select all

data:extend{
  {
    type = "technology",
    name = "speed-module-4",
    icon_size = 64,
    icon = "__MoreModules__/graphics/icons/speed-module-4.png",
    effects = {
      {
        type = "unlock-recipe",
        recipe = "speed-module-4"
      }
    },
    prerequisites = {"speed-module-3"},
    unit = {
      count = 500,
      ingredients = {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
        {"chemical-science-pack", 1},
        {"production-science-pack", 1}
      },
      time = 60
    },
	
    order = "i-c-d"
  },
  {
  
    type = "technology",
    name = "speed-module-5",
    icon_size = 64,
    icon = "__MoreModules__/graphics/icons/speed-module-5.png",
    effects = {
      {
        type = "unlock-recipe",
        recipe = "speed-module-5"
      }
    },
    prerequisites = {"speed-module-4"},
    unit = {
      count = 1000,
      ingredients = {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
        {"chemical-science-pack", 1},
        {"production-science-pack", 1},
        {"utility-science-pack", 1} -- Adding High Tech Science Pack requirement
      },
      time = 90
    },
    order = "i-c-e"
  },
  {
  
    type = "technology",
    name = "speed-module-6",
    icon_size = 64,
    icon = "__MoreModules__/graphics/icons/speed-module-6.png",
    effects = {
      {
        type = "unlock-recipe",
        recipe = "speed-module-6"
      }
    },
    prerequisites = {"speed-module-5"},
    unit = {
      count = 2000,
      ingredients = {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
        {"chemical-science-pack", 1},
        {"production-science-pack", 1},
        {"utility-science-pack", 1},
		{"space-science-pack", 10} -- Adding Space Tech Science Pack requirement
      },
      time = 120
    },
    order = "i-c-f"
  },
}
data.lua

Code: Select all

require("prototypes.item.productivity-modules")
require("prototypes.item.efficiency-modules")
require("prototypes.item.speed-modules")
require("prototypes.item.godule-modules")
require("prototypes.recipe.productivity-modules-recipes")
require("prototypes.recipe.efficiency-modules-recipes")
require("prototypes.recipe.speed-modules-recipes")
require("prototypes.recipe.godule-modules-recipes")
require("prototypes.technology.productivity-modules-technologies")
require("prototypes.technology.efficiency-modules-technologies")
require("prototypes.technology.speed-modules-technologies")
require("prototypes.technology.godule-modules-technologies")
This is the issue as visible in game:
20240822145549_1.jpg
20240822145549_1.jpg (129.65 KiB) Viewed 489 times
Edited with correct code.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 1:04 pm
by Bilka
Thank you. In that code you're not copying or modifying anything in any way that may mess with other prototypes, that's what I was looking for.

So there is most likely some code in another mod rewriting the recipe. Maybe even in bobequipment itself. You could try to search there first, if there is code that modifies the recipes it's probably in https://github.com/modded-factorio/bobs ... pdates.lua.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 1:07 pm
by Darknesspk89
Thank you, I will check there and see what I can do.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 1:14 pm
by Darknesspk89
Yep, I found this:

Code: Select all

if data.raw.module["effectivity-module-4"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk4-equipment", "effectivity-module-3", "effectivity-module-4")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-2", "effectivity-module-3", "effectivity-module-4")
end

if data.raw.module["speed-module-4"] then
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-2", "speed-module-3", "speed-module-4")
end

if data.raw.module["productivity-module-4"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk4-equipment", "productivity-module-3", "productivity-module-4")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-2", "productivity-module-3", "productivity-module-4")
end

if data.raw.module["effectivity-module-6"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk5-equipment", "effectivity-module-3", "effectivity-module-6")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-3", "effectivity-module-3", "effectivity-module-6")
end

if data.raw.module["speed-module-6"] then
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-3", "speed-module-3", "speed-module-6")
end

if data.raw.module["productivity-module-6"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk5-equipment", "productivity-module-3", "productivity-module-6")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-3", "productivity-module-3", "productivity-module-6")
end

if data.raw.module["effectivity-module-8"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk6-equipment", "effectivity-module-3", "effectivity-module-8")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-4", "effectivity-module-3", "effectivity-module-8")
end

if data.raw.module["speed-module-8"] then
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-4", "speed-module-3", "speed-module-8")
end

if data.raw.module["productivity-module-8"] then
  bobmods.lib.recipe.replace_ingredient("energy-shield-mk6-equipment", "productivity-module-3", "productivity-module-8")
  bobmods.lib.recipe.replace_ingredient("fusion-reactor-equipment-4", "productivity-module-3", "productivity-module-8")
Is there any way to prevent this from happening besides changing the names of my modules? Or changing Bobs manually of course, but I want to be able to upload my mod if I feel satisfied with it.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 2:05 pm
by Bilka
You could change the recipe back afterwards in your own mod (optionally depend on bobequipment and then change the recipes in data-updates). You could also try to ask the maintainer of the mod if they can add some way to prevent the change.

Re: Unintentionally changing recipes from another mod

Posted: Thu Aug 22, 2024 2:30 pm
by Darknesspk89
Thanks for all the help Bilka, I think I got it working now :)