My mod introduces a new entity of type "assembling-machine". This entity's crafting_categories is set to {"custom-test"}, a crafting category my mod defines. The modded assembler is otherwise a clone of assembling-machine-1.
My modded assembler works correctly. The only recipes that appear in its interface are those added by my mod in the custom-test category.
However, none of these recipes can be crafted by hand.
None of the recipes involve fluids, which I know makes them ineligable for hand-crafting. The recipes can be hand-crafted if the category is omitted or set to "crafting", but then they appear in assembling machines, which is precisely what I am trying to prevent.
Looking at the game files, I think that only recipes with either no category or "crafting" category can be hand-crafted. However, some recipes have -or-hand-crafting in their categories.
I tried giving a recipe the category "custom-test-or-hand-crafting". This resulted in an error that the category does not exist.
How do I add recipes to a mod-defined category that the player can hand-craft?
Or, how do I restrict hand-craftable recipes to only one machine?
Custom mod category or-hand-crafting
Re: Custom mod category or-hand-crafting
I believe the recipes a player can craft is based on character's prototype's crafting_categories. Usually, that's data.raw.character.character.crafting_categories, I think. Adding your category to that table should do it?
Not sure where a player without a character gets their recipe list from, like in sandbox mode.
Not sure where a player without a character gets their recipe list from, like in sandbox mode.
Re: Custom mod category or-hand-crafting
Thank you! I didn't realise the player character is simply an entity that can be modded like anything else. I found it in the base entities.lua as "character".Silari wrote: Tue Sep 22, 2026 1:01 am I believe the recipes a player can craft is based on character's prototype's crafting_categories. Usually, that's data.raw.character.character.crafting_categories, I think. Adding your category to that table should do it?
Not sure where a player without a character gets their recipe list from, like in sandbox mode.
For future reference, this adds categories to hand-crafting:
Code: Select all
data.raw["character"]["character"].crafting_categories = {"crafting", "custom-test"}Omitting "crafting" restricts the player to only the custom recipe category. That does seem useful for some types of mods.
Out of curiosity, I did try leaving it empty {}. That results in an error. Apparently, the player needs to be able to craft something for the game to launch. That makes sense.
I am not sure about sandbox either. To be honest, I forgot it existed as distinct from doing /editor in a normal game.
Re: Custom mod category or-hand-crafting
This solution will create conflicts with other mods that want to add crafting categories. A cleaner solution would only add this crafting category instead of overwriting all.
You could probably read the existing crafting categories, which is an array of strings, then add another entry to that array and then set the crafting categories that array. I do not know how to add an entry to an array in lua, but that should not be that hard.
It seems like array.insert just inserts the given string to the last entry of the array, which should provide the desired result.
Here is an attempt [untested]:
You could probably read the existing crafting categories, which is an array of strings, then add another entry to that array and then set the crafting categories that array. I do not know how to add an entry to an array in lua, but that should not be that hard.
It seems like array.insert just inserts the given string to the last entry of the array, which should provide the desired result.
Here is an attempt [untested]:
Code: Select all
data.raw["character"]["character"].crafting_categories.insert("custom_test")


