Adding recipes to a new category?...

Place to get help with not working mods / modding interface.
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Adding recipes to a new category?...

Post by Volvith »

Hi guys,

I'm currently changing a few things in a mod i downloaded, no hand crafting by Y.Petermann.
I want to change the newly added "burner assembling-machine" to only be able to craft a specific set of items.

How can i assign existing base mod recipes to a custom category?
Do i literally just add the new category after the already present one in existing recipes in the "Factorio\data\base\prototypes\etc..." files?

Code: Select all

  {
    type = "recipe",
    name = "express-transport-belt",
    category = "crafting-with-fluid" "custom category here",
    enabled = false,
    ingredients =
    {
      {"iron-gear-wheel", 5},
      {"fast-transport-belt", 1},
      {type="fluid", name="lubricant", amount=2},
    },
    result = "express-transport-belt",
    requester_paste_multiplier = 4
  },
Can i create a new recipes file in the mod's folder to overwrite the base mod one?
Also, how come that 80% of the native recipes have no assigned category?
...
I started working with factorio mods and lua in general, about 3 hours ago, so any help you can offer is more than welcome!... :D
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Adding recipes to a new category?...

Post by Rseding91 »

If no category is defined it defaults to "crafting". Since the majority of the base-game recipes fall into that category they just don't define it and use the default value.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Re: Adding recipes to a new category?...

Post by Volvith »

Rseding91 wrote:If no category is defined it defaults to "crafting". Since the majority of the base-game recipes fall into that category they just don't define it and use the default value.
Thanks for the help! :)
That would explain why the assembler showed the entire list of items without them having a "crafting" category.

Quick question, can i extend the categories on recipes like this?:

Code: Select all


data:extend({
	{
		type = "recipe",
		name = "example-recipe-1",
		category = "rainbowsparkleponies"
	},
	{
		type = "recipe",
		name = "example-recipe-2",
		category = "rainbowtwinkleponies"
	},
})

Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Adding recipes to a new category?...

Post by Rseding91 »

You have to define the categories like all other prototypes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Adding recipes to a new category?...

Post by bobingabout »

Define a category like this:

Code: Select all

data:extend(
{
  {
    type = "recipe-category",
    name = "electrolysis"
  },
  {
    type = "recipe-category",
    name = "distillery"
  },
}
end
Then use those categories on the recipe.

Code: Select all

data:extend(
{
  {
    type = "recipe",
    name = "pure-water",
    category = "distillery",  -- <<< This line here!
    energy_required = 2,
    ingredients =
    {
      {type = "fluid", name = "water", amount = 100},
    },
    results =
    {
      {type = "fluid", name = "pure-water", amount = 100},
    },
    subgroup = "bob-fluid",
    icon = "__bobplates__/graphics/icons/pure-water.png",
    order = "b[fluid-chemistry]-b[pure-water-1]",
  },
}
end
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Re: Adding recipes to a new category?...

Post by Volvith »

Okay, so the general structure for recipes and their categories and such is a bit more clear to me now.
However, the problem i'm having is i'm trying to create a new assembling machine that only produces a specific set of base mod items.
The reason i want to add this functionality to the mod i'm creating is that i don't want it to create all items with up to 3 ingredients, and i want to limit progress.

Basically i have 2 questions left:
How do i overwrite or add to an already existing base mod recipe?
How can i assign multiple categories to a single recipe?

EDIT:
Okay, so i've come to the point where i've created this list of items i want my assembling machine to have access to, modifying their recipes to have 2 different categories, "crafting" and the newly added "burner-assembling-machine".
This would enable my new burner assembling machine to only pick up the items with the "burner-assembling-machine" category, while the rest of the game would still pick the same recipes up with the "crafting" category.

Code for the specified list (complete file, no additional formatting or anything):

Code: Select all

data.raw["recipe"]["wooden-chest"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["transport-belt"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["small-electric-pole"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["pipe"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["pipe-to-ground"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["iron-axe"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["boiler"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["steam-engine"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["burner-mining-drill"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["offshore-pump"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["stone-furnace"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["lab"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["wood"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["copper-cable"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["iron-stick"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["iron-gear-wheel"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["electronic-circuit"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["science-pack-1"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["burner-inserter"].category = {"burner-assembling-machine", "crafting"}
data.raw["recipe"]["burner-assembling-machine"].category = {"burner-assembling-machine", "crafting"}
The problem is, the items added to this list are removed from the game when the mod is active.
They're not just inaccessible by my custom assembling machine, but are removed completely, and return the moment i disable my mod.

I have created the category "burner-assembling-machine", i have linked the category to the entity that is the burner assembling machine in question, i have set the category for the burner assembling machine's recipe to "burner-assembling-machine", i have linked all files up with data.lua (The "require" function.), i have quintuple-checked that all the formatting and spelling checks out, and i have NO clue what i'm doing wrong.
If i had to guess, it's probably the data.raw list listed above, as i have no clue how to format it properly, but i'm basically shouting answers to an unknown equation here.
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Adding recipes to a new category?...

Post by bobingabout »

Category on a recipe can only have a single entry, not a table.

You need to do the reverse, set a new category on the recipe, then add that category to all machines you want to be able to make that item, which means adding your burner-assembling-machine category to all other assembling machines, and the player entity too if you want the player to be able to make it.


I would give you an example where I do it in my mods, but first I would have to download my mods here (at work), then rewrite it to present it to you in plain form, as I use functions and just call those to make my life easier. The electronic crafting machines in my assembling machines mod uses it (and others do too), and you'll also need my library mod for the function if you intend to look it up.


There are however issues with this, removing anything from the "crafting" category means that the creative mode god entity is then no longer able to craft the item.
I have asked for a solution to this (The ability to add to the god mode crafting category, AND the ability to use a table for categories on the recipe) but nothing has been done about it yet.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Re: Adding recipes to a new category?...

Post by Volvith »

Yeah, i figured that that would be the problem, with the recipe's rejecting a category.
So i moved on the the latter part indeed, (although for some reason the game is still not taking it...).

I wonder though, is there any way to simply list the recipe's themselves in an assembling machine?
Or is there any kind of way that i can circumnavigate the categories when listing recipes for an assembling machine to craft?
Because at this point, i truly have come to believe that duct-taping the whole category system like this does more harm than good.

Would i perhaps be able to write a script or a function where, when the player is a god-entity, the categories default back to simply "crafting"?...

Also, i have to add that i might have downloaded all your mods, extracted them, and just started digging through nearly all the code to find, even if half-assed, a solution to this.
Either way, i'm gonna look around in the meantime to see what kind of monstrosity i can frankenstein together. :3
Cheers mate! ^^

EDIT:
So, i got it up and running properly now, turns out i did indeed do something wrong with the category re-assignment in the data.updates file.
Put a normal-true style if on it, works flawlessly.

You were right about the god mode thing, though not to the extend i expected.
I expected the items to be uncraftable even in cheat-mode (looking back, idk why), which is not so much the case.
Rather, it disables the items in vanilla god-mode.

Is it possible to make a new category craftable in god-mode?...
If not then that's just one of the downsides of the mod until i find a solution, or one is included by the Factorio devs. :/
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16016
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Adding recipes to a new category?...

Post by Rseding91 »

bobingabout wrote:There are however issues with this, removing anything from the "crafting" category means that the creative mode god entity is then no longer able to craft the item.
I have asked for a solution to this (The ability to add to the god mode crafting category, AND the ability to use a table for categories on the recipe) but nothing has been done about it yet.
I fixed that for the current released version of 0.15.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Volvith
Inserter
Inserter
Posts: 40
Joined: Mon Jun 26, 2017 12:28 pm
Contact:

Re: Adding recipes to a new category?...

Post by Volvith »

Rseding91 wrote:I fixed that for the current released version of 0.15.
Ok, wow, that's one problem off my chest... xD
Thanks for the notice.

Also, kinda off-topic but not:

Code: Select all

local crafting_cap = 0
for i, obj in pairs(data.raw["recipe"]) do
  if (crafting_categories[obj.category] or obj.category == "" or obj.category == nil) then
    if #obj.ingredients > crafting_cap then
      crafting_cap = #obj.ingredients
    end
  end
end
data.raw["assembling-machine"]["assembling-machine-1"].ingredient_count = crafting_cap
With something along the lines of this in data-updates, would it be possible to increase the ingredient_count for a (few) specific recipe(s) in the assembling-machine-1?
I could just create a massive code sheet that basically redefines all the categories for every recipe available in assembling machine 1 and 2, and add those to the assemblers, but you know...
Non-existent mod-compatibility and such... :[

EDIT:
Welp, for the time being, my mod is about as compatible with other mods as a slightly moldy loaf of bread... :3
I'm probably just gonna write a conversion script for a few significant mods, because i have no clue how to fix this issue otherwise.
...
I'm not a smart man. xD
Mama.always["told-me"]["that"].life = {"box-of-chocolates"}
"Failed to load: __Existence__/My-Life: 12358132135: attempt to index global 'life' (a nil value)

Mods to be disabled:
▪ Hope"
Rational People: If it ain't fucked, don't fuck it.
Engineers: If it ain't fucked, unfuck it till it's perfect.
Me as an Engineer: If it ain't fucked, i'll fuck it till it is.
Post Reply

Return to “Modding help”