[0.17.68] script.on_configuration_changed happens too soon?
Posted: Fri Sep 06, 2019 1:25 am
So I'm using script.on_configuration_changed to unlock recipes that should be unlocked if the player is adding this mod to a game in progress. I use the following function:
When I load the save, the matching print statements fire. But the expected recipes are not unlocked! If I copy/paste from the first for loop to the matching end and paste it as a command, the recipes unlock as expected.
The running mods list are as follows:
The only mods here that aren't mine are Bob's Logistics and Fill4Me.
Code: Select all
function retroactivate()
global.MTBF_meddling = global.MTBF_meddling or {}
--log("Performing migration.")
game.print("Doing migration 1")
for _, force in pairs(game.forces) do
for __, tech in pairs(force.technologies) do
if tech.researched then
for ___, effect in pairs(tech.effects) do
if effect.type == "unlock-recipe" and string.find(effect.recipe, "broken-") then
game.print("Doing migration 2")
force.recipes[effect.recipe].enabled = true
force.recipes["robot-control-module"].enabled = true
force.recipes["robot-powercell"].enabled = true
force.recipes[string.gsub(effect.recipe, "broken%-", "disassemble-")].enabled = true
end
end
end
end
end
end
The running mods list are as follows:
Code: Select all
72.872 Checksum for script __Assembler_Assay__/control.lua: 550528542
72.898 Checksum for script __BeltUpgrader__/control.lua: 1699357547
72.914 Checksum for script __Bot_Servicing__/control.lua: 770765553
72.916 Checksum for script __Concreep__/control.lua: 2984749389
72.926 Checksum for script __Dirt_Path__/control.lua: 1160991668
72.953 Checksum for script __Fill4Me__/control.lua: 89059952
72.954 Checksum for script __MoreAchievements__/control.lua: 3879118096
72.956 Checksum for script __boblogistics__/control.lua: 3426676619