Unlock recipe on specific infinite tech level

Place to get help with not working mods / modding interface.
Post Reply
User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Unlock recipe on specific infinite tech level

Post 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.

kikker450
Inserter
Inserter
Posts: 30
Joined: Fri May 05, 2017 9:07 am
Contact:

Re: Unlock recipe on specific infinite tech level

Post 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.

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: Unlock recipe on specific infinite tech level

Post 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.

Post Reply

Return to “Modding help”