Page 1 of 1

Add alternative recipe for a vanilla item

Posted: Sun May 04, 2014 7:38 pm
by darkrising
Hello, I've just started looking at factorio modding and I tried to make a mod that would allow you to craft alien science packs from the other science packs (1 of each to be exact)

I have a little skeleton mod going with one recipe however the recipe does not show in the game.

Is it possible to add alternative recipes to vanilla items and if so how would I add one in?

Thanks in advance.

Re: Add alternative recipe for a vanilla item

Posted: Sun May 04, 2014 8:48 pm
by darkrising
I'm an idiot, I called the recipe name the exact same thing as the vanilla item!
I didn't realise they used the exact same naming convention as me.

All sorted :)

Re: Add alternative recipe for a vanilla item

Posted: Sun May 04, 2014 10:24 pm
by Ultimoos
Actually, I was about to look that up myself. Could I ask you to share how you resolved this problem?

Re: Add alternative recipe for a vanilla item

Posted: Mon May 05, 2014 11:06 am
by darkrising
Ultimoos wrote:Actually, I was about to look that up myself. Could I ask you to share how you resolved this problem?
I've actually released a mod with the alternative recipe, if you want you can download it and look at the code, here's a link: https://forums.factorio.com/forum/vie ... =14&t=3373 :)

All it really is:
-modname-/prototypes/recipe/alien-science.lua

Code: Select all

data:extend(
{
	{
		type = "recipe",
		name = "alien-science-pack2", --the original recipe is called alien-science-pack
    energy_required = 12,
		ingredients = {
			{"science-pack-1", 6},
			{"science-pack-2", 3},
			{"science-pack-3", 1}
		},
		result = "alien-science-pack"
	}
})

Re: Add alternative recipe for a vanilla item

Posted: Tue May 06, 2014 6:04 pm
by Ultimoos
So all you really do is add a recipe and as a result you give it a vanilla item. So game uses your recipe instead of vanillas. But to achieve that, your recipe has to be loaded after game loads all vanilla mod stuff. Do you somehow have to make sure that game loads your mod last, or it somehow happens automatically?
I'm asking this because situation where we use multiple mods that overwrites the same item is very possible, and that game has to know in what order should it load all those mods?
Sorry, for making this so complicated ;)

Re: Add alternative recipe for a vanilla item

Posted: Thu May 15, 2014 10:34 pm
by NSArray
Ultimoos wrote:Do you somehow have to make sure that game loads your mod last
If you add

Code: Select all

"dependencies": ["base >= 0.9.8"]
to your info.json file, the game will make sure that your mod loads after "base" which is the main game. You can also add multiple different dependencies of other mods if you want your mod to load after those.

Re: Add alternative recipe for a vanilla item

Posted: Tue May 20, 2014 5:16 pm
by Ultimoos
Thanks, it all makes sense now.