Page 1 of 1

Unlock recipe on specific infinite tech level

Posted: Fri May 05, 2017 9:26 am
by moon69
Hi,

I'm modding some upgraded electric-mining-drills for 0.15, and I thought an easy way to gate them initially is with specific levels of infinite technology "mining productivity", but the following code claims "mining-productivity-3 not found" when the mod is loaded at Factorio launch...

Code: Select all

table.insert(data.raw["technology"]["mining-productivity-3"].effects, {type = "unlock-recipe",recipe = "my-electric-drill-2"})
table.insert(data.raw["technology"]["mining-productivity-7"].effects, {type = "unlock-recipe",recipe = "my-electric-drill-3"})
Is it possible?

Thanks.

Re: Unlock recipe on specific infinite tech level

Posted: Fri May 05, 2017 10:05 am
by kikker450
If you look at the raw data files (Factorio\data\base\prototypes\technology\technology.lua) you can see that mining-productivity-1, 4, 8 and 16 are hard-code and those in-between and after are upgrades of those and thus generated in game (after loading). You can take the easy route and hard-code it with on of the pervious mentioned stages or you have to figure something out while it is researched ingame like checking it exists or not and if it's researched or not:

if game.player*.force.technology["mining-productivity-3"] and game.player.force.technology[""mining-productivity-3"].researched then
-- your_recipe.enabled = true
end

*you get the player from an event object
(this code hasn't been tested btw so don't be suprised if the syntax doesn't work.)

Or you could add that specific level of mining-productivity into the datafiles while reducing the max upgrade of the previous stage.

Re: Unlock recipe on specific infinite tech level

Posted: Fri May 05, 2017 1:14 pm
by moon69
Marvellous thank you - 1, 4, 8 are fine for my quick & dirty testing... I'll find a more appropriate place in the tech tree once I play test.