Page 1 of 1

Researched all technologies before science pack 3

Posted: Thu Mar 15, 2018 5:12 pm
by WIZ4
How can I research all technologies before science pack 3?
I tried to use it, but it research all technologies:

Code: Select all

for k, force in pairs (game.forces) do
	for k, technology in pairs (force.technologies) do
		for k, ingredient in pairs (technology.research_unit_ingredients) do
			if ingredient.name ~= 'science-pack-3' then 
			technology.researched = true
			end
		end	
	end
end

Re: Researched all technologies before science pack 3

Posted: Thu Mar 15, 2018 6:30 pm
by betrok

Code: Select all

for k, force in pairs (game.forces) do
   for k, technology in pairs (force.technologies) do
      local before_3 = true
      for k, ingredient in pairs (technology.research_unit_ingredients) do
         if ingredient.name == 'science-pack-3' then
          before_3 = false
         end
      end
      if before_3 than
        technology.researched = true
      end
   end
end
I did not test it though.

Re: Researched all technologies before science pack 3

Posted: Thu Mar 15, 2018 6:45 pm
by WIZ4
betrok wrote:

Code: Select all

for k, force in pairs (game.forces) do
   for k, technology in pairs (force.technologies) do
      local before_3 = true
      for k, ingredient in pairs (technology.research_unit_ingredients) do
         if ingredient.name == 'science-pack-3' then
          before_3 = false
         end
      end
      if before_3 than
        technology.researched = true
      end
   end
end
I did not test it though.
Yes, it worked, thanks:)