Page 1 of 1
Technology/Research Unlocks
Posted: Mon Feb 09, 2015 8:42 pm
by mngrif
I'm wanting to have an existing technology unlock an item/recipe I have added. Is there a way to extend an existing technology to also unlock my recipes?
Thank you.
Re: Technology/Research Unlocks
Posted: Mon Feb 09, 2015 8:44 pm
by Rseding91
Yes, you'd want to do that in the data.lua (or other staged variant).
This would add the recipe unlock "compression-chest" to the "logistics-3" research:
Code: Select all
table.insert(data.raw["technology"]["logistics-3"].effects,{type="unlock-recipe",recipe="compression-chest"})
Keep in mind, this doesn't retroactively unlock the recipe if you load the mod into a game where logistics-3 has already been researched.
To fix that you'd need to read FreeER's reply below

Re: Technology/Research Unlocks
Posted: Mon Feb 09, 2015 8:55 pm
by FreeER
Rseding91 wrote:Yes, you'd want to do that in the data.lua (or other staged variant).
the other staged variants are data-updates.lua and data-final-fixes.lua (loaded in that order, they mostly allow not specifying as many optional dependencies for other mods). Also you'd want to make sure that if someone adds the mod to an already started save that it unlocks the recipe as desired

The best way to do that is a migration script, create a folder called "migrations" and add a .lua file inside (name is usually mod-version and/or date or just something relevant) and use this code
Code: Select all
for _, force in pairs(game.forces) do
force.resetrecipes()
force.resettechnologies()
-- create tech/recipe table once
local techs = force.technologies
local recipes = force.recipes
if techs["logistics-3"].researched then
recipes["compression-chest"].enabled = true
end
end
Rseding91 you should see
this post by kovarex
Re: Technology/Research Unlocks
Posted: Mon Feb 09, 2015 9:20 pm
by Rseding91
FreeER wrote:Rseding91 you should see
this post by kovarex
Ah yes, that's what I was looking for. Thanks.
Re: Technology/Research Unlocks
Posted: Mon Feb 09, 2015 11:14 pm
by mngrif
Thank you both so much

I should be able to publish it today.
I spent about 20 minutes searching the forums and wiki for an answer but apparently I can't search worth crap.