Is there any solution to remove an unlock item from a mod tech, without changeing the other mod?
Example.
In my case, an other mod will unlock an item with a tech. i want to remove this item, beacause my mod unlock this item before. And the other mod shows it up twice (in his Mod Categorie).
Remove unlock Item from MOd Tech
Remove unlock Item from MOd Tech
please notice that my natove language is german, so my english is not so good. Thx
Re: Remove unlock Item from MOd Tech
You should change the other mod's technology prototype in data-updates.lua. What you're interested in is the "effects" property, which can be defined in technology.effects, technology.normal.effects, and technology.expensive.effects. Just look for effects of type "unlock-recipe" and remove those that unlock your item:BOFan80 wrote: Tue Apr 19, 2022 9:39 am Is there any solution to remove an unlock item from a mod tech, without changeing the other mod?
Code: Select all
local function remove_recipe_unlock(tech_name, recipe_name)
local tech = tech_name and data.raw.technology[tech_name]
if tech then
local function remove(effects, recipe_name)
if effects then
for e = #effects, 1, -1 do
if effects[e].type == "unlock-recipe" and effects[e].recipe == recipe_name then
table.remove(effects, e)
end
end
end
end
remove(tech.effects, recipe_name)
remove(tech.normal and tech.normal.effects, recipe_name)
remove(tech.expensive and tech.expensive.effects, recipe_name)
end
end
remove_recipe_unlock("steel-processing", "steel-plate")
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: Remove unlock Item from MOd Tech
Thx after the Edit it works. You help me realy a lot
please notice that my natove language is german, so my english is not so good. Thx
Re: Remove unlock Item from MOd Tech
You're welcome! By the way, in case you wondered why I was going over the loop backwards: the ingredients list is a sorted array with subsequent indexes (1, 2, 3 …), no gaps between them. If you remove the second entry, everything following will be shifted down, so old element 3 would be new element 2, old 4 new 3 etc. But the loop wouldn't notice that. If you're at i=2 and remove that, you'd skip the old element 3 and jump directly to the old element 4 on the next iteration. So going backwards makes sure that you don't miss anything.
However, I must have confused ingredients with something else. Just noticed this::
So you can simplify the loop:Duplicate ingredients, e.g. two entries for the "wood" item, are not allowed.
Code: Select all
for e, effect in pairs(effects) do
if effects.type == "unlock-recipe" and effects.recipe == recipe_name then
table.remove(effects, e)
break
end
end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!