Modded Item Not Unlocked

Looking for a mod? Have a review on a mod you'd like to share?
Post Reply
adam_bise
Filter Inserter
Filter Inserter
Posts: 359
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Modded Item Not Unlocked

Post by adam_bise »

I downloaded a burner pump mod and added it to an existing game. The item is researched with fluid handling. I have already researched fluid handling and the item is not unlocked unless I start a new game.

My question is, is there a way for me to unlock the burner pump without starting a new game or disabling my achievements?

BTW this is a multiplayer game.

adam_bise
Filter Inserter
Filter Inserter
Posts: 359
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Modded Item Not Unlocked

Post by adam_bise »

This is what I get when I try to fix. I don't want to disable achievements.

2021-11-14 12:50:17 [WARNING] Player <server> tried using the command "game.player.force.technologies['fluid-handling'].researched=false".
2021-11-14 12:50:17 [WARNING] Using Lua console commands will disable achievements. Please repeat the command to proceed.

adam_bise
Filter Inserter
Filter Inserter
Posts: 359
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Modded Item Not Unlocked

Post by adam_bise »

Here is a link to the mod in question.

https://mods.factorio.com/mod/burner-pump

adam_bise
Filter Inserter
Filter Inserter
Posts: 359
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Modded Item Not Unlocked

Post by adam_bise »

I also thought about modding the mod..

I found some info about control.lua and on_init or on_configuration_changed, but don't know what to try. If I use on_init and remove and re-add the mod, will it run?

Also, where do you say "on_init"? This is the code snippet I wanted to try:

Code: Select all

for _, force in pairs(game.forces) do
    if force.technologies["some-technology"].researched then
        force.recipes["my-recipe"].enabled = true
    end
end

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 489
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Modded Item Not Unlocked

Post by Silari »

The mod is missing a migration to enable the recipe. They go into a folder named 'migrations'. For example, for my Alternate Recipes mod, the migration for it is 'Alternate_Recipes_1.1.0\migrations\enable-recipes2.lua'

The following code should handle it if put into the migrations folder.

Code: Select all

for index, force in pairs(game.forces) do
    local technologies = force.technologies
    local recipes = force.recipes
    for nindex, effect in pairs(technologies["fluid-handling"].effects) do
        --Set the recipe as researched if fluid-handling is.
        if effect.type == "unlock-recipe" then
            recipes[effect.recipe].enabled = technologies["fluid-handling"].researched
        end
    end
end
You can name the file whatever you want, it just has to be in the migrations folder and end in '.lua'.

adam_bise
Filter Inserter
Filter Inserter
Posts: 359
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Modded Item Not Unlocked

Post by adam_bise »

Nice! Worked like a charm. Thank you!

Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Modded Item Not Unlocked

Post by Pi-C »

Silari wrote:
Sun Nov 14, 2021 7:25 pm
The mod is missing a migration to enable the recipe. […]

You can name the file whatever you want, it just has to be in the migrations folder and end in '.lua'.
In this case, where it's just about applying effects to already researched technologies again, I'd even consider running the code from on_configuration_changed instead of a migration file. Reason: Other mods be may added/removed after your mod's migration script has run (each migration script is applied at most once per game), and if they add new prerequisites to your tech, you may want to un-research it again.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Questions, reviews and ratings”