Changing what deposits drop

Place to get help with not working mods / modding interface.
Post Reply
FlyingPotato
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Aug 20, 2016 11:45 pm
Contact:

Changing what deposits drop

Post by FlyingPotato »

Alright, so I've scoured everywhere searching for an answer, as well as tried some things on my own, but nothing seems to work properly.

Is there a way to make the ore deposits that are already in the base game drop an item other than the original iron/copper ores?

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Changing what deposits drop

Post by aubergine18 »

Yes, just change 'result' property of a resource prototype:

Code: Select all

data:extend{
  {
    type = "resource",
    name = 'copper-ore',
    icon = "__base__/graphics/icons/copper-ore.png",
    flags = {"placeable-neutral"},
    order="a-b-a",
    minable =
    {
      hardness = 0.9,
      mining_particle = "copper-ore-particle",
      mining_time = 2,
      result = 'copper-ore'  <---------------------- THIS
    },
    collision_box = {{ -0.1, -0.1}, {0.1, 0.1}},
    selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
    autoplace = autoplace_settings('copper-ore', 0.02),
    stage_counts = {1000, 600, 400, 200, 100, 50, 20, 1},
    stages =
    {
      sheet =
      {
        filename = "__base__/graphics/entity/copper-ore/copper-ore.png",
        priority = "extra-high",
        width = 38,
        height = 38,
        frame_count = 4,
        variation_count = 8
      }
    },
    map_color = {r=0.803, g=0.388, b=0.215}
  }
}
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

FlyingPotato
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Aug 20, 2016 11:45 pm
Contact:

Re: Changing what deposits drop

Post by FlyingPotato »

Alright, so that worked... sort of. I just straight copied and pasted that into my code, and then changed the result to "iron-ore" just for testing. When I ran factorio, I got the error that calling autoplace_settings was a nil value (or something similar) so I added the autoplace_settings from the demo-recipies prototype in the entities. Now my code is this:

Code: Select all

local function autoplace_settings(name, coverage)
  local ret = {
    control = name,
    sharpness = 1,
    richness_multiplier = 1500,
    richness_multiplier_distance_bonus = 20,
    richness_base = 500,
    coverage = coverage,
    peaks = {
      {
        noise_layer = name,
        noise_octaves_difference = -1.5,
        noise_persistence = 0.3,
      },
    }
  }
end

  data:extend{
  {
    type = "resource",
    name = 'copper-ore',
    icon = "__base__/graphics/icons/copper-ore.png",
    flags = {"placeable-neutral"},
    order="a-b-a",
    minable =
    {
      hardness = 0.9,
      mining_particle = "copper-ore-particle",
      mining_time = 2,
      result = 'iron-ore'  --<---------------------- THIS
    },
    collision_box = {{ -0.1, -0.1}, {0.1, 0.1}},
    selection_box = {{ -0.5, -0.5}, {0.5, 0.5}},
    autoplace = autoplace_settings('copper-ore', 0.02),
    stage_counts = {1000, 600, 400, 200, 100, 50, 20, 1},
    stages =
    {
      sheet =
      {
        filename = "__base__/graphics/entity/copper-ore/copper-ore.png",
        priority = "extra-high",
        width = 38,
        height = 38,
        frame_count = 4,
        variation_count = 8
      }
    },
    map_color = {r=0.803, g=0.388, b=0.215}
  }
}
Now copper ore deposits from my old saves give iron ore. However, copper ore deposits aren't showing up on new worlds at all.

FlyingPotato
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Aug 20, 2016 11:45 pm
Contact:

Re: Changing what deposits drop

Post by FlyingPotato »

Nevermind, I realized I hadn't copied the whole autoplace_settings function. Works perfectly now, thank you!

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Changing what deposits drop

Post by prg »

Instead of duplicating all of that code you could just leave the existing prototype definition as it is and only change the one thing you care about.

Code: Select all

data.raw.resource["copper-ore"].minable.result = "iron-ore"
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Post Reply

Return to “Modding help”