As in the old map display new recipes mod

Place to get help with not working mods / modding interface.
Post Reply
Airat9000
Smart Inserter
Smart Inserter
Posts: 1418
Joined: Fri Mar 28, 2014 12:32 am
Contact:

As in the old map display new recipes mod

Post by Airat9000 »

As in the old map display new recipes, for example a new kind of recipe or technology.
which codes change everything, and output in the old map?

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: As in the old map display new recipes mod

Post by Adil »

Добавляй русский перевод к своим постам. Непонятно же ничего.
Тебе походу вот это нужно.
kovarex wrote:To make this mod work correctly for existing saves there needs to be added the migration to it.

This is the migration we will have in 0.9.5 to fix the lubricant problem:

Code: Select all

game.player.force.resettechnologies() -- The technology is different now, so we need to update the version player has

for index, force in pairs(game.forces) do
  if force.technologies["oil-processing"].researched then -- When the oil processing is already researched, we need to enable the lubricant
    force.recipes["lubricant"].enabled = true
  end
end
The migration is special code that is run only when you load save with your mod, that didn't have it before.

So you should put file in the mod (put it in the migrations folder) that will contain this:

Code: Select all

game.player.force.resettechnologies() -- The technology is different now, so we need to update the version player has

for index, force in pairs(game.forces) do
  if force.technologies["oil-processing"].researched then -- When the oil processing is already researched, we need to enable the the recipes it unlocks
    force.recipes["fill-water-barrel"].enabled = true
    force.recipes["empty-water-barrel"].enabled = true
    force.recipes["fill-heavy-oil-barrel"].enabled = true
    force.recipes["empty-heavy-oil-barrel"].enabled = true
    force.recipes["fill-light-oil-barrel"].enabled = true
    force.recipes["empty-light-oil-barrel"].enabled = true
    force.recipes["fill-petroleum-gas-barrel"].enabled = true
    force.recipes["empty-petroleum-gas-barrel"].enabled = true
    force.recipes["fill-lubricant-barrel"].enabled = true
    force.recipes["empty-lubricant-barrel"].enabled = true
    force.recipes["fill-sulfuric-acid-barrel"].enabled = true
    force.recipes["empty-sulfuric-acid-barrel"].enabled = true
    force.recipes["liquid-station"].enabled = true
  end
end
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”