Dont know how to add a recipe code-wise

Place to get help with not working mods / modding interface.
Post Reply
QuintupleDude
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Dec 08, 2017 10:20 pm
Contact:

Dont know how to add a recipe code-wise

Post by QuintupleDude »

I want to add a recipe that does a type of ore refining that does this (this recipe comes with oil processing), in a chemical plant , put 5 ore and 10 light oil , get 6 ore , put 6 ore and 10 heavy oil , get 7 ore , put 7 ore and 10 petrolum gas get 8 ore , i want a example mod that i could work with if anyone could help , thanks!!!!!!

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Dont know how to add a recipe code-wise

Post by darkfrei »

As example:
Factorio\data\base\prototypes\recipe\fluid-recipe.lua

Code: Select all

  {
    type = "recipe",
    name = "sulfuric-acid",
    category = "chemistry",
    energy_required = 1,
    enabled = false,
    ingredients =
    {
      {type="item", name="sulfur", amount=5},
      {type="item", name="iron-plate", amount=1},
      {type="fluid", name="water", amount=100}
    },
    results=
    {
      {type="fluid", name="sulfuric-acid", amount=50}
    },
    subgroup = "fluid-recipes",
    crafting_machine_tint =
    {
      primary = {r = 0.875, g = 0.735, b = 0.000, a = 0.000}, -- #dfbb0000
      secondary = {r = 0.103, g = 0.940, b = 0.000, a = 0.000}, -- #1aef0000
      tertiary = {r = 0.564, g = 0.795, b = 0.000, a = 0.000}, -- #8fca0000
    }
  }
or

Code: Select all

  {
    type = "recipe",
    name = "plastic-bar",
    category = "chemistry",
    energy_required = 1,
    enabled = false,
    ingredients =
    {
      {type="fluid", name="petroleum-gas", amount=20},
      {type="item", name="coal", amount=1}
    },
    results=
    {
      {type="item", name="plastic-bar", amount=2}
    },
    crafting_machine_tint =
    {
      primary = {r = 0.498, g = 0.498, b = 0.498, a = 0.000}, -- #7f7f7f00
      secondary = {r = 0.400, g = 0.400, b = 0.400, a = 0.000}, -- #66666600
      tertiary = {r = 0.305, g = 0.305, b = 0.305, a = 0.000}, -- #4d4d4d00
    }
  }
Just make new mod, info.json, then in data.lua add new code

Code: Select all

data:extend({
 -- here
})
:!: :!: :!: For better modding you are need https://notepad-plus-plus.org/

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Dont know how to add a recipe code-wise

Post by bobingabout »

if you do simply want to add recipes from existing items, follow the steps above (they're all quotes from the base game).

if you want new intermediate items (the ore in each step is actually a new one, not the original), you'll need to add those items too.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
Shenpen
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Aug 27, 2016 2:46 pm
Contact:

Re: Dont know how to add a recipe code-wise

Post by Shenpen »

Klonans old modding introduction is still worth paying attention to:

https://www.youtube.com/watch?v=8lPNOOVYeMU&t=932s

Post Reply

Return to “Modding help”