Page 1 of 1

Trying to make a recipe category

Posted: Thu Apr 07, 2016 3:40 pm
by TurtleZ
Hello. I have just started writing a mod for Factorio and I cannot seem to get recipe categories working.

I followed the tutorial by Klonan, and got a mod working up to that stage. I then added a custom recipe, and got it showing up in my new entity.

I then wanted to add a custom recipe category (which I found out about by looking through Factorio's base files and another mod) so that it would only show up in my entity and not in the base game ones, but whenever I load up Factorio now I get a "Error in AssignID, recipe-category with name "-name of category-" does not exist".

I do not see why it works for the mod I was copying it from but not for mine! I copied everything pretty much and just changed the names around.

The code I currently have is this: (this is all within the prototypes folder)
  • entity.lua

    Code: Select all

    data:extend({
    
    {
        type = "assembling-machine",
        name = "distillation-column",
        icon = "__base__/graphics/icons/oil-refinery.png",
        flags = {"placeable-neutral","player-creation"},
        minable = {mining_time = 2, result = "distillation-column"},
        max_health = 350,
        corpse = "big-remnants",
        dying_explosion = "medium-explosion",
        collision_box = {{-2.4, -2.4}, {2.4, 2.4}},
        selection_box = {{-2.5, -2.5}, {2.5, 2.5}},
        module_specification =
        {
          module_slots = 3
        },
        allowed_effects = {"consumption", "speed", "productivity", "pollution"},
        crafting_categories = {"distillation"},
        crafting_speed = 1,
        has_backer_name = true,
        energy_source =
        {
          type = "electric",
          usage_priority = "secondary-input",
          emissions = 0.02 / 3.5
        },
        energy_usage = "300kW",
        ingredient_count = 4,
        animation =
        {
          north =
          {
            filename = "__base__/graphics/entity/oil-refinery/oil-refinery.png",
            width = 337,
            height = 255,
            frame_count = 1,
            shift = {2.515625, 0.484375}
          },
          east =
          {
            filename = "__base__/graphics/entity/oil-refinery/oil-refinery.png",
            x = 337,
            width = 337,
            height = 255,
            frame_count = 1,
            shift = {2.515625, 0.484375}
          },
          south =
          {
            filename = "__base__/graphics/entity/oil-refinery/oil-refinery.png",
            x = 674,
            width = 337,
            height = 255,
            frame_count = 1,
            shift = {2.515625, 0.484375}
          },
          west =
          {
            filename = "__base__/graphics/entity/oil-refinery/oil-refinery.png",
            x = 1011,
            width = 337,
            height = 255,
            frame_count = 1,
            shift = {2.515625, 0.484375}
          }
        },
        working_visualisations =
        {
          {
            north_position = {1.03125, -1.55},
            east_position = {-1.65625, -1.3},
            south_position = {-1.875, -2.0},
            west_position = {1.8437, -1.2},
            animation =
            {
              filename = "__base__/graphics/entity/oil-refinery/oil-refinery-fire.png",
              frame_count = 29,
              width = 16,
              height = 35,
              scale = 1.5,
              shift = {0, -0.5625},
              run_mode="backward"
            },
            light = {intensity = 0.4, size = 6}
          }
        },
        vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
        working_sound =
        {
          sound = { filename = "__base__/sound/oil-refinery.ogg" },
          idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 0.6 },
          apparent_volume = 2.5,
        },
        fluid_boxes =
        {
          {
            production_type = "input",
            pipe_covers = pipecoverspictures(),
            base_area = 10,
            base_level = -1,
            pipe_connections = {{ type="input", position = {-1, 3} }}
          },
          {
            production_type = "input",
            pipe_covers = pipecoverspictures(),
            base_area = 10,
            base_level = -1,
            pipe_connections = {{ type="input", position = {1, 3} }}
          },
          {
            production_type = "output",
            pipe_covers = pipecoverspictures(),
            base_level = 1,
            pipe_connections = {{ position = {-2, -3} }}
          },
          {
            production_type = "output",
            pipe_covers = pipecoverspictures(),
            base_level = 1,
            pipe_connections = {{ position = {0, -3} }}
          },
          {
            production_type = "output",
            pipe_covers = pipecoverspictures(),
            base_level = 1,
            pipe_connections = {{ position = {2, -3} }}
          }
  • item.lua

    Code: Select all

    data:extend({
    {
        type = "item",
        name = "distillation-column",
        icon = "__base__/graphics/icons/oil-refinery.png",
        flags = {"goes-to-quickbar"},
        subgroup = "production-machine",
        order = "e[distillation-column]",
        place_result = "distillation-column",
        stack_size = 10
      }
      })
  • recipe.lua and technology.lua (problem is not in this code I don't think).
  • A folder called "categories", containing recipe-category.lua.

    Code: Select all

    data:extend({
        {
            type = "recipe-category",
            name = "distillation"
        }
    })
I have also attached the mod in case you need to see anything else or test it yourself.

Thank you.

TurtleZ

Re: Trying to make a recipe category

Posted: Thu Apr 07, 2016 3:52 pm
by prg
You're missing a

Code: Select all

data:extend({
    {
        type = "recipe-category",
        name = "distillation"
    }
})
somewhere.

Re: Trying to make a recipe category

Posted: Thu Apr 07, 2016 4:02 pm
by TurtleZ
prg wrote:You're missing a

Code: Select all

data:extend({
    {
        type = "recipe-category",
        name = "distillation"
    }
})
somewhere.
Whoops, I do have that, just copied the wrong code into the code boxes. Fixed it now. :D

Re: Trying to make a recipe category

Posted: Thu Apr 07, 2016 4:09 pm
by prg
Right, then the problem becomes that just having that definition sit around in some file somewhere isn't enough, you also need to require that file from data.lua like the others for it to do anything useful.

Re: Trying to make a recipe category

Posted: Thu Apr 07, 2016 4:22 pm
by TurtleZ
prg wrote:Right, then the problem becomes that just having that definition sit around in some file somewhere isn't enough, you also need to require that file from data.lua like the others for it to do anything useful.
Thank you very much! It works now! :D :D