on_research_finished and LuaRecipe.enabled

This subforum contains all the issues which we already resolved.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

on_research_finished and LuaRecipe.enabled

Post 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.
My mods on the Factorio Mod Portal :geek:
Rseding91
Factorio Staff
Factorio Staff
Posts: 14942
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_research_finished and LuaRecipe.enabled

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: on_research_finished and LuaRecipe.enabled

Post 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 .
My mods on the Factorio Mod Portal :geek:
Post Reply

Return to “Resolved Problems and Bugs”