Page 1 of 1

[0.18.47] [Lua] on_research_finished gives incorrect research

Posted: Tue Aug 11, 2020 9:19 pm
by timboo07up
When having an research that has multiple levels (e.g. infinite research) the on_research_finished gives off the wrong level.
I have not tested it with lower levels (e.g. mining-productivity-[1-3]). but with infinite research levels this is certainly the case.

Setup:

factorio default settings
in the mod:
- using the event_handler.lua from core
- use a lib {events = {[defines.events.on_research_complete] => function() end} }
- In this
The added screenshot should show exactly the issue. Since i would assume that it would show the actual researched tech.
It also has the researched: false.

So it seems to me it points to the incorrect tech (aka the next in the list, instead of the actual researched one)
You get the same value/tech in the game.forces.player.previous_research in that event.

I would expect that it would show the correct level that has been researched, not the one that can be researched.

(minimized control.lua attached)

Re: [0.18.47] [Lua] on_research_finished gives incorrect research

Posted: Tue Aug 11, 2020 9:23 pm
by Rseding91
Thanks for the report however that's just how that works; infinite research is just 1 technology and the researched-level on it keeps getting increased as it is researched more. So there is no "previous" one to send to the event - just "the" technology.

If you want to know what level of an infinite technology was just researched just take the current level - 1.

Re: [0.18.47] [Lua] on_research_finished gives incorrect research

Posted: Tue Aug 11, 2020 10:10 pm
by timboo07up
Was kind of expecting that.
Thank you for the reply, but it feels like its somewhat incorrect.
From a tech perspective i get that its that way. But it took me a while to figure it out.

So you're saying: if level > 1 then level = level -1.

I can live with that. although it might be helpfull to have that documented somewhere near the event documentation.
Anyhow this one can be closed if its not going to get fixed