on_research_finished and techno researched status not true

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

on_research_finished and techno researched status not true

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

Re: on_research_finished and techno researched status not true

Post 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
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 techno researched status not true

Post 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 :-)
My mods on the Factorio Mod Portal :geek:
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: on_research_finished and techno researched status not true

Post 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")
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1525
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: on_research_finished and techno researched status not true

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

Return to “Modding discussion”