Good evening.
I'm currently making a mod that adds a modified roboport. I am wanting to tech this roboport behind the vanilla roboport, but I want the player to have to use this modified roboport before using the vanilla one.
In order to do that, I'm wanting to move the vanilla roboport to the logistics system, and then remove the recipe unlock from both Logistics and Construction robotics and add in the new recipe. Unfortunately, I can't figure out how to do this, and I can't seem to find any guide that illustrates a good way to do this.
Any help would be appreciated
Move a recipe to a different technology
Move a recipe to a different technology
Author of Advanced Factorio, a set of mods that add small bits of Advanced functionality to your gameplay
Check it out here: https://mods.factorio.com/user/neomore
Check it out here: https://mods.factorio.com/user/neomore
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Move a recipe to a different technology
Well, adding to an existing technology is fairly easy.
this example is from my library, so has a fair bit of safety adding to it, to make sure other mods didn't outright delete the technology or something.
instead of technology, you'd use... "logistic-robots" or whatever your technology is, and likewise recipe would be "roboport".
The first few lines in this are just to make sure the recipe and technology exist, and if the technology doesn't have an effects table, add it, the final line (before the last end) is the one doing the actual job.
To remove is a little harder, since you have to cycle through all the items in the list, then remove the right one.
again, since this is just from my library, the first line is checking to make sure that the technology exists, and that it has an effects table.
this example is from my library, so has a fair bit of safety adding to it, to make sure other mods didn't outright delete the technology or something.
instead of technology, you'd use... "logistic-robots" or whatever your technology is, and likewise recipe would be "roboport".
The first few lines in this are just to make sure the recipe and technology exist, and if the technology doesn't have an effects table, add it, the final line (before the last end) is the one doing the actual job.
Code: Select all
if data.raw.technology[technology] and data.raw.recipe[recipe] then
if not data.raw.technology[technology].effects then
data.raw.technology[technology].effects = {}
end
table.insert(data.raw.technology[technology].effects,{type = "unlock-recipe", recipe = recipe})
end
Code: Select all
if data.raw.technology[technology] and data.raw.technology[technology].effects then
for i, effect in pairs(data.raw.technology[technology].effects) do
if effect.type == "unlock-recipe" and effect.recipe == recipe then
table.remove(data.raw.technology[technology].effects,i)
end
end
end
Re: Move a recipe to a different technology
For whatever reason, I wasn't able to get this to work. I was able to get it to work by making your library a dependency and usingbobingabout wrote:Well, adding to an existing technology is fairly easy.
this example is from my library, so has a fair bit of safety adding to it, to make sure other mods didn't outright delete the technology or something.
instead of technology, you'd use... "logistic-robots" or whatever your technology is, and likewise recipe would be "roboport".
The first few lines in this are just to make sure the recipe and technology exist, and if the technology doesn't have an effects table, add it, the final line (before the last end) is the one doing the actual job.To remove is a little harder, since you have to cycle through all the items in the list, then remove the right one.Code: Select all
if data.raw.technology[technology] and data.raw.recipe[recipe] then if not data.raw.technology[technology].effects then data.raw.technology[technology].effects = {} end table.insert(data.raw.technology[technology].effects,{type = "unlock-recipe", recipe = recipe}) end
again, since this is just from my library, the first line is checking to make sure that the technology exists, and that it has an effects table.Code: Select all
if data.raw.technology[technology] and data.raw.technology[technology].effects then for i, effect in pairs(data.raw.technology[technology].effects) do if effect.type == "unlock-recipe" and effect.recipe == recipe then table.remove(data.raw.technology[technology].effects,i) end end end
Code: Select all
bobmods.lib.tech.remove_recipe_unlock
![Confused :?](./images/smilies/icon_e_confused.gif)
I'm still having issues with add_recipe_unlock, but i think that's on my code's end and not yours.
Author of Advanced Factorio, a set of mods that add small bits of Advanced functionality to your gameplay
Check it out here: https://mods.factorio.com/user/neomore
Check it out here: https://mods.factorio.com/user/neomore
Re: Move a recipe to a different technology
I managed to get the everything working finally. however, I found another issue that needs a workaround.
Is there some way to reload recipes after the technology has already been completed. I know that "migrations" can do this, but as far as I am aware, migrations doesn't work when going from "no mod -> mod".
Also, I should mention that I am making this mod for 0.15 and then upgrading it to 0.16 afterward, since i forgot to post that initially.
Is there some way to reload recipes after the technology has already been completed. I know that "migrations" can do this, but as far as I am aware, migrations doesn't work when going from "no mod -> mod".
Also, I should mention that I am making this mod for 0.15 and then upgrading it to 0.16 afterward, since i forgot to post that initially.
Author of Advanced Factorio, a set of mods that add small bits of Advanced functionality to your gameplay
Check it out here: https://mods.factorio.com/user/neomore
Check it out here: https://mods.factorio.com/user/neomore
Re: Move a recipe to a different technology
We have on_configuration_changed http://lua-api.factorio.com/latest/LuaB ... on_changed and can be useful reset_recipes http://lua-api.factorio.com/latest/LuaF ... et_recipesNeomore wrote:Is there some way to reload recipes after the technology has already been completed. I know that "migrations" can do this, but as far as I am aware, migrations doesn't work when going from "no mod -> mod".
Also
force.reset_technologies()
Load the original versions of technologies from prototypes. Preserves research state of technologies.
force.reset_technology_effects()
Reapplies all possible research effects, including unlocked recipes. Any custom changes are lost. Preserves research state of technologies.