KirkMcDonald / factorio-tools

Tools dealing with the game Factorio.
50 stars 28 forks source link

factoriodump generates "results": [ [] ] #11

Open abesto opened 4 years ago

abesto commented 4 years ago

The output of factoriodump on my (heavily modded, details below) installation includes entries with "results": [ [] ] that he web UI barfs on. Looking at the rest of the JSON file, it looks like this is indeed not valid content.

Example

        "cobalt-oxide-from-copper": {
                "amount": 1,
                "name": "stone",
                "type": "item"
            }, {
                "amount": 1,
                "name": "solid-carbon",
                "type": "item"
            }, {
                "amount": 5,
                "name": "gas-hydrogen",
                "type": "fluid"
            } ],
            "localized_name": {
                "en": "Advanced copper processing with Cobalt oxide"
            },
            "main_product": "copper-plate",
            "name": "cobalt-oxide-from-copper",
            "order": "c-b[cobalt-oxide-from-copper]",
            "results": [ [], [] ],
            "subgroup": "bob-material-chemical",
            "type": "recipe"
        },

Environment

Side-note

I understand this is probably a weird edge-case that only comes up with tons of complex mods. Then again, a calculator is especially useful in such a playthrough. And who knows, maybe it's an easy fix, or highlights some other problem that was hiding so far, so thought I'd submit this anyway.

🌈

abesto commented 4 years ago

Managed to dig out the .lua source for the recipe in the example:

{
    type = "recipe",
    name = "cobalt-oxide-from-copper",
    icon = "__bobplates__/graphics/icons/copper-cobalt-oxide.png",
    icon_size = 32,
    subgroup = "bob-material-chemical",
    order = "c-b[cobalt-oxide-from-copper]",
    category = "chemical-furnace",
    energy_required = 25,
    enabled = false,
    ingredients =
    {
      {type = "item", name = "copper-ore", amount = 7},
      {type = "item", name = "stone", amount = 1},
      {type = "item", name = "carbon", amount = 1},
      {type = "fluid", name = "hydrogen", amount = 5},
    },
    results=
    {
      {type = "item", name = "copper-plate", amount_min = 7, amount_max = 11},
      {type = "item", name = "cobalt-oxide", amount_min = 1, amount_max = 3},
    },
    main_product= "copper-plate",
    allow_decomposition = false
  },
abesto commented 4 years ago

And verified with an fmt.Println that the incorrect data is already present in getJSON() after executing the Lua stuff.