Make item only craftable within a certain machine

Place to get help with not working mods / modding interface.
Post Reply
Kino_
Burner Inserter
Burner Inserter
Posts: 13
Joined: Mon Jul 09, 2018 5:56 am
Contact:

Make item only craftable within a certain machine

Post by Kino_ »

I've been searching for a while now but can't seem to find the answer to this simple question for the life of me.

How can I force a recipe to only be craftable inside a certain machine? So that they player can't hand craft and they have to use an assembling machine.

The answer is probably really simple but I can't find it wherever I look

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Make item only craftable within a certain machine

Post by eradicator »

With crafting categories. Defaults to "crafting" if not explicitly defined in a recipe.

Code: Select all

--machine:
{
  type = "assembling-machine",
  name = "assembling-machine-2",
  crafting_categories = {"crafting", "advanced-crafting", "crafting-with-fluid"
  --etc...
  },
{
  type = "player",
  name = "player",
  crafting_categories = {"crafting"},
  --etc...
  }
--recipe:
{
  type = "recipe",
  name = "engine-unit",
  category = "advanced-crafting",
  --etc...
  }, 
{
  type = "recipe",
  name = "electric-engine-unit",
  category = "crafting-with-fluid",
  --etc...
  }
--category:
{
    type = "recipe-category",
    name = "advanced-crafting"
  },
  
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: Make item only craftable within a certain machine

Post by bobingabout »

Yeah, if you just want assembling machines, you could use the crafting category advanced-crafting.
if you're making it for a specific assembling machine, you could add a new category to the machine you want it to be crafted in, then use that on the recipe.

if you're adding new categories, don't forget that they need to be defined before you can use them too. I think all they need is a type, and name. I think the type is "crafting-category", but I'm not certain.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Make item only craftable within a certain machine

Post by eradicator »

bobingabout wrote:
Fri Nov 02, 2018 8:54 am
if you're adding new categories, don't forget that they need to be defined before you can use them too. I think all they need is a type, and name. I think the type is "crafting-category", but I'm not certain.
Type, Name, done. See the end of the code example above. Type is "recipe-category" though, probably for "historic reasons" :p.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: Make item only craftable within a certain machine

Post by bobingabout »

eradicator wrote:
Fri Nov 02, 2018 3:38 pm
bobingabout wrote:
Fri Nov 02, 2018 8:54 am
if you're adding new categories, don't forget that they need to be defined before you can use them too. I think all they need is a type, and name. I think the type is "crafting-category", but I'm not certain.
Type, Name, done. See the end of the code example above. Type is "recipe-category" though, probably for "historic reasons" :p.
advanced-crafting is one you added? Fair enough then.

I think bob's mods adds "machine-crafting" to assembling machines. crafting-with-fluid is a good go to, but that means it's excluded from assembling machine 1.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Make item only craftable within a certain machine

Post by eradicator »

bobingabout wrote:
Fri Nov 02, 2018 7:51 pm
advanced-crafting is one you added? Fair enough then.
No. Those are just quoted bits from vanilla. I didn't add anything there.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”