Page 1 of 1
on_research_finished and techno researched status not true
Posted: Sat May 07, 2016 2:07 pm
by binbinhfr
I noticed that in the call to on_research_finished event,
the value of player.force.technology[researched_techno].researched was not true yet.
Is it voluntary ?
Re: on_research_finished and techno researched status not true
Posted: Sat May 07, 2016 4:17 pm
by Rseding91
It's fixed for 0.13.
Also you should be using the event.research that the event passes instead of re-looking up the research. The event only gets fired when research is completed so you can know for sure the research is researched that's being passed from the event.
http://lua-api.factorio.com/0.12.33/eve ... h_finished
Re: on_research_finished and techno researched status not true
Posted: Sun May 08, 2016 8:52 am
by binbinhfr
Rseding91 wrote:It's fixed for 0.13.
Also you should be using the event.research that the event passes instead of re-looking up the research. The event only gets fired when research is completed so you can know for sure the research is researched that's being passed from the event.
http://lua-api.factorio.com/0.12.33/eve ... h_finished
ok for the fix.
because for now I use :
Code: Select all
--------------------------------------------------------------------------------------
function on_research_finished(event)
if event.research ~= nil and event.research.name == "camera-drones" then
local player
for _,player in pairs(game.players) do
player.print( player.name .. " drones researched = " .. tostring(player.force.technologies["camera-drones"].researched) )
init_player(player)
end
end
end
script.on_event(defines.events.on_research_finished, on_research_finished )
and it effectively always displays "false".
so the call to my function init_player (that is used in other cases), that tests the techno.researched status, is bad. But I will do a turnaround, waiting for 0.13

Re: on_research_finished and techno researched status not true
Posted: Tue May 10, 2016 10:09 am
by bobingabout
Considering this is an event that triggers when the research is completed, you could just use the line:
Code: Select all
player.print( player.name .. " drones researched = true")
Re: on_research_finished and techno researched status not true
Posted: Tue May 10, 2016 3:10 pm
by binbinhfr
bobingabout wrote:Considering this is an event that triggers when the research is completed, you could just use the line:
Code: Select all
player.print( player.name .. " drones researched = true")
hé hé, that's what I wanted to show : for the moment, it does not write "true", but "false" !
will be corrected in 0.13 as rseding said.