[2.0.23] RecipePrototype feature "auto_recycle" is undocumented in API Docs

Place to report issues and suggest improvements to the API documentation.
PyroGamer666
Burner Inserter
Burner Inserter
Posts: 16
Joined: Fri Aug 28, 2020 5:37 am
Contact:

[2.0.23] RecipePrototype feature "auto_recycle" is undocumented in API Docs

Post by PyroGamer666 »

This is a bug within Factorio's documentation, not with Factorio itself.

The current version of Factorio's documentation does not document the "auto_recycle" recipe-prototype feature, which appears to control if a recipe is reversible via recyclers. Without documentation for this feature, modders will not know how to mark recipes as irreversible.

https://lua-api.factorio.com/latest/pro ... otype.html

This is an example of "auto_recycle" within Space Age's source code, in the recipe for carbon fiber.

Code: Select all

    type = "recipe",
    name = "carbon-fiber",
    category = "organic",
    subgroup = "agriculture-products",
    order = "a[organic-products]-h[carbon-fiber]",
    auto_recycle = false,
    energy_required = 5,
    enabled = false,
    ingredients =
    {
      {type = "item", name = "yumako-mash", amount = 10},
      {type = "item", name = "carbon", amount = 1}
    },
    results = {{type="item", name="carbon-fiber", amount=1}},
    allow_productivity = true,
    crafting_machine_tint =
    {
      primary = {r = 0.306, g = 0.643, b = 0.684, a = 1.000},
      secondary = {r = 0.684, g = 0.684, b = 0.684, a = 1.000},
    },
  },
I believe the reason this feature is undocumented is because it's not used by the engine in any way. Instead, the auto_recycle feature is only relevant when it's checked by the Quality mod to determine if it should generate a recycling recipe. I could be wrong. Here is an excerpt from the Quality mod where "auto_recycle" is checked to determine if it should auto-generate a recycling recipe.

Code: Select all

local default_can_recycle = function(recipe)
  if recipe.category == "recycling" then return end

  -- Allow recipes to opt-out
  if recipe.auto_recycle == false then return end

  -- Disallow smelting and chemistry recipes
  if recipe.subgroup == "empty-barrel" then return end

  if recipe.category == "smelting" then return end
  if recipe.category == "chemistry" then return end

  if recipe.category == "chemistry-or-cryogenics" and recipe.name ~= "battery" then return end
  if recipe.category == "crushing" then return end

  local recycling_metallurgy = {["big-mining-drill"]=true, ["turbo-transport-belt"]=true, ["turbo-underground-belt"]=true, ["turbo-splitter"]=true}
  if recipe.category == "metallurgy" and recycling_metallurgy[recipe.name] == nil then return end
  if recipe.category == "organic" then return end

  if recipe.category == "cryogenics" and recipe.name ~= "railgun-turret" and recipe.name ~= "railgun" and recipe.name ~= "cryogenic-plant" and recipe.name ~= "fusion-reactor" and recipe.name ~= "fusion-generator" then return end
  if string.find(recipe.name, "science") and string.find(recipe.name, "pack") then return end
  -- Items which go into T3 modules recycle into themselves
  if recipe.name == "tungsten-carbide" then return end
  if recipe.name == "superconductor" then return end
  if recipe.name == "biolab" then return end

  return true
end
The reason why this improvised feature doesn't crash the game is because immediately after generating recycling recipes, the Quality mod removes auto_recycle from every recipe in the game.

Code: Select all

for name, recipe in pairs(data.raw.recipe) do
  recycling.generate_recycling_recipe(recipe)
  recipe.auto_recycle = nil
end
User avatar
PennyJim
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Re: [2.0.23] RecipePrototype feature "auto_recycle" is undocumented in API Docs

Post by PennyJim »

First of all, it wouldn't crash even if Quality didn't remove the field. Extra fields are ignored and don't cause an exception.

Second, see also: 120859
Post Reply

Return to “Documentation Improvement Requests”