Technology/Research Unlocks

Place to get help with not working mods / modding interface.
Post Reply
User avatar
mngrif
Fast Inserter
Fast Inserter
Posts: 173
Joined: Wed Feb 13, 2013 10:44 am
Contact:

Technology/Research Unlocks

Post 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.
My Silly Factorian Tricks
<_aD> OBSERVE SIGNAL ASPECT BEFORE CROSSING TRACK

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Technology/Research Unlocks

Post 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 :)
Last edited by Rseding91 on Mon Feb 09, 2015 9:19 pm, edited 1 time in total.
If you want to get ahold of me I'm almost always on Discord.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Technology/Research Unlocks

Post 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
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Technology/Research Unlocks

Post by Rseding91 »

FreeER wrote:Rseding91 you should see this post by kovarex
Ah yes, that's what I was looking for. Thanks.
If you want to get ahold of me I'm almost always on Discord.

User avatar
mngrif
Fast Inserter
Fast Inserter
Posts: 173
Joined: Wed Feb 13, 2013 10:44 am
Contact:

Re: Technology/Research Unlocks

Post 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.
My Silly Factorian Tricks
<_aD> OBSERVE SIGNAL ASPECT BEFORE CROSSING TRACK

Post Reply

Return to “Modding help”