Page 1 of 1

on_research_finished and LuaRecipe.enabled

Posted: Wed Jul 20, 2016 1:07 am
by binbinhfr
Hi,

it seems that in on_research_finished event, when you try to read recipe.enabled on the recipes that have just been found, it gives false

example : research automation and in on_research_finished event, print :
game.forces.player.recipes["assembling-machine-1"].enabled and game.forces.player.recipes["long-handed-inserter"].enabled )
it will give false false

if you do it afterwards, outside the event, it will give true true.

Re: on_research_finished and LuaRecipe.enabled

Posted: Wed Jul 20, 2016 8:10 am
by Rseding91
Don't reference technologies directly like that - it's wrong in 3 ways:

1. The research being completed doesn't have to be on the player force so using game.forces.player is incorrect
3. The research being completed is passed in the event parameters: event.research
2. The research being completed doesn't have to contain "assembling-machine-1" even if it is the automation research - use event.research.effects to see what the technology will actually do

As for it not applying effects before calling the event, fixed for 0.13.10.

Re: on_research_finished and LuaRecipe.enabled

Posted: Wed Jul 20, 2016 8:16 am
by binbinhfr
Rseding91 wrote:Don't reference technologies directly like that
Of course rseding :-) it was only to show you the bug quickly. But I originaly noticed it while properly reading parameter event.research.effects.recipe .