Add alternative recipe for a vanilla item

Place to get help with not working mods / modding interface.
User avatar
darkrising
Inserter
Inserter
Posts: 26
Joined: Sun May 04, 2014 7:32 pm
Contact:

Add alternative recipe for a vanilla item

Post 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.
User avatar
darkrising
Inserter
Inserter
Posts: 26
Joined: Sun May 04, 2014 7:32 pm
Contact:

Re: Add alternative recipe for a vanilla item

Post 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 :)
Ultimoos
Burner Inserter
Burner Inserter
Posts: 18
Joined: Fri May 02, 2014 8:48 am
Contact:

Re: Add alternative recipe for a vanilla item

Post by Ultimoos »

Actually, I was about to look that up myself. Could I ask you to share how you resolved this problem?
User avatar
darkrising
Inserter
Inserter
Posts: 26
Joined: Sun May 04, 2014 7:32 pm
Contact:

Re: Add alternative recipe for a vanilla item

Post 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"
	}
})
Ultimoos
Burner Inserter
Burner Inserter
Posts: 18
Joined: Fri May 02, 2014 8:48 am
Contact:

Re: Add alternative recipe for a vanilla item

Post 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 ;)
NSArray
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 15, 2014 1:06 am
Contact:

Re: Add alternative recipe for a vanilla item

Post 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.
Ultimoos
Burner Inserter
Burner Inserter
Posts: 18
Joined: Fri May 02, 2014 8:48 am
Contact:

Re: Add alternative recipe for a vanilla item

Post by Ultimoos »

Thanks, it all makes sense now.
Post Reply

Return to “Modding help”