Page 1 of 1

Dont know how to add a recipe code-wise

Posted: Mon Dec 25, 2017 8:07 pm
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!!!!!!

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

Posted: Mon Dec 25, 2017 9:17 pm
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/

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

Posted: Tue Dec 26, 2017 2:26 am
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.

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

Posted: Wed Dec 27, 2017 11:05 am
by Shenpen
Klonans old modding introduction is still worth paying attention to:

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