Skip to content

Loading fails if item has both normal and expensive recipe #5

@hohounk

Description

@hohounk

I'm playing a custom modpack with K2+SE+246k and a whole lot of other smaller mods. During startup I get this error (line numbers are off because I added some debug code):
image

The issue is in this part of the code:

        ingredients = {
          {"nanotubes", 6},
          table.unpack(util.table.deepcopy(data.raw.recipe["imersium-plate"].ingredients)),
        },

The debug code I added just dumped out data.raw.recipe["imersium-plate"].ingredients and data.raw.recipe["imersium-plate"]

As was obvious from the error message, the first one returned nil. The other one gave the full thing, though:

{
  allow_productivity = true,
  always_show_made_in = true,
  always_show_products = true,
  category = "smelting",
  expensive = {
    always_show_made_in = true,
    always_show_products = true,
    category = "smelting",
    enabled = false,
    energy_required = 32,
    ingredients = {
      {
        amount = 9,
        name = "imersite-powder",
        type = "item"
      },
      {
        amount = 6,
        name = "rare-metals",
        type = "item"
      },
      {
        amount = 4,
        name = "fi_crushed_crystal_item",
        type = "item"
      }
    },
    results = {
      {
        amount = 3,
        name = "imersium-plate",
        type = "item"
      }
    }
  },
  icons = {
    {
      icon = "__Krastorio2Assets__/icons/items/imersium-plate.png",
      icon_size = 64
    }
  },
  mod = "Krastorio2",
  name = "imersium-plate",
  normal = {
    always_show_made_in = true,
    always_show_products = true,
    category = "smelting",
    enabled = false,
    energy_required = 32,
    ingredients = {
      {
        amount = 9,
        name = "imersite-powder",
        type = "item"
      },
      {
        amount = 6,
        name = "rare-metals",
        type = "item"
      },
      {
        amount = 4,
        name = "fi_crushed_crystal_item",
        type = "item"
      }
    },
    results = {
      {
        amount = 3,
        name = "imersium-plate",
        type = "item"
      }
    }
  },
  subgroup = "raw-material",
  type = "recipe"
}

Long story short, if an item has both normal and expensive recipe the code breaks.
I'm not sure how to fix this easily as I've not really done much lua coding outside of similar debugging of factorio mods.

If you wish me to do some more testing or debugging or give a modlist/savegame (without carbon mod as it won't load, naturally) just let me know. I'd love to help you any way I can

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions