Crafting Categories

Place to get help with not working mods / modding interface.
Omegamachine
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Nov 19, 2024 12:14 am
Contact:

Crafting Categories

Post by Omegamachine »

I'm new to modding and just messing around a bit. I've followed the basic tutorial creating the fire armor and looked at some existing mods - but i can't figure out crafting categories. I can change the crafting category of the item so that it is craftable in different machines but making a new category has stumped me. Here is my current code;

Code: Select all

--data.lua

local function sprite(name)
  return '__chem-craft__/graphics/'..name
  end
  
  
--Create a new recipe category called chemistry-vials
data:extend(
{
  {
    type = "recipe-category",
    name = "chemistry-vials"
  },
}
)

--Add the recipe category to the chemical plant, so that it can now craft this new category.
--i assume this is where i've gone wrong
table.insert(data.raw["assembling-machine"]["chemical-plant"].crafting_categories, "chemistry-vials")

--create the item using iron-plate as a template
local Resource_Oxygen = table.deepcopy(data.raw["item"]["iron-plate"])

Resource_Oxygen.name = "oxygen-vial"
Resource_Oxygen.icons = {
  {
    icon      =  sprite('Oxygen.png'),
    icon_size = 64,
    --tint = {r=1,g=0,b=0,a=0.3}
  },
}
Resource_Oxygen.stack_size = 100

-- create a recipe for the item
local OxygenRecipe = {
  type = "recipe",
  name = "oxygen-vial",
  category = "chemistry-vials",
  enabled = true,
  energy_required = 1,
  ingredients = {
    {type = "item", name = "copper-plate", amount = 200},
    {type = "item", name = "steel-plate", amount = 50}
  },
  results = {{type = "item", name = "oxygen-vial", amount = 1}}
}

data:extend{Resource_Oxygen, OxygenRecipe}
Thanks for any guidance
Natha
Filter Inserter
Filter Inserter
Posts: 304
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Crafting Categories

Post by Natha »

What is not working?
Omegamachine
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Nov 19, 2024 12:14 am
Contact:

Re: Crafting Categories

Post by Omegamachine »

I guess it's not actually adding the new category to the chemistry plant. If i ctrl+shift+F the chemistry bench in game it shows the crafting categories as the default 4, chemistry, chemistry-or-cryogenics, organic-or-chemistry, parameters. If i ctrl+shift+F the item recipe oxygen-vial it does show the category id as chemistry-vials.

i've tried a few other things like:

Code: Select all

 local CraftingCategory_Vials = table.deepcopy(data.raw["recipe-category"]["chemistry-or-cryogenics"])
CraftingCategory_Vials.name = "chemistry-vials"
table.insert(data.raw["assembling-machine"]["chemical-plant"].crafting_categories, CraftingCategory_Vials )
but that produces an error.
thanks.
Natha
Filter Inserter
Filter Inserter
Posts: 304
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Crafting Categories

Post by Natha »

Try to insert the category in data-final-fixes.lua
Omegamachine
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Nov 19, 2024 12:14 am
Contact:

Re: Crafting Categories

Post by Omegamachine »

Natha wrote: Mon Jan 19, 2026 8:50 pm Try to insert the category in data-final-fixes.lua
yeah that totally worked, thank you!
Post Reply

Return to “Modding help”