Remove Vanilla Ores

Place to get help with not working mods / modding interface.
Post Reply
Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Remove Vanilla Ores

Post by Suf »

Hi all :D
So i'm trying to make mod that has ores but i need to remove the vanilla related ores like iron ,copper etc,however i don't know from where should i start to able to do that.Any help would be appreciated.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Remove Vanilla Ores

Post by darkfrei »

Suf wrote:
Fri Jul 10, 2020 5:22 am
Hi all :D
So i'm trying to make mod that has ores but i need to remove the vanilla related ores like iron ,copper etc,however i don't know from where should i start to able to do that.Any help would be appreciated.

Code: Select all

data.raw.resource["iron-ore"] = nil
or just

Code: Select all

data.raw.resource["iron-ore"].autoplace = nil

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Remove Vanilla Ores

Post by Suf »

So i've tried that and it removed the ores in-game but in map settings or while in map editing they're still there.is there a way to remove all of that as well?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Remove Vanilla Ores

Post by darkfrei »

Suf wrote:
Fri Jul 10, 2020 10:46 am
So i've tried that and it removed the ores in-game but in map settings or while in map editing they're still there.is there a way to remove all of that as well?
Maybe also:

Code: Select all

data.raw["noise-layer"]["iron-ore"] = nil
and

Code: Select all

data.raw["autoplace-control"]["iron-ore"] = nil
and from presets:

Code: Select all

data.raw["map-gen-presets"].default["rich-resources"].basic_settings.autoplace_controls["iron-ore"] = nil

data.raw["map-gen-presets"].default["rail-world"].basic_settings.autoplace_controls["iron-ore"] = nil

data.raw["map-gen-presets"].default["ribbon-world"].basic_settings.autoplace_controls["iron-ore"] = nil

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Remove Vanilla Ores

Post by Suf »

the first one has no effect; the ore on map generator still there and in game still there
the second one gave me this error :Error in assignID: autoplace-control with name 'iron-ore' does not exist. It was removed by my mod
the third one(presets) has no effect same as the first line

mpratt
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Feb 14, 2017 5:28 am
Contact:

Re: Remove Vanilla Ores

Post by mpratt »

Here's the function I use, it removes it from all the autoplace controls and then removes the resource itself:

Code: Select all

local function RemoveResource(resource, fromResourceList)
	local map_gen_presets = data.raw["map-gen-presets"]["default"]

  data.raw["autoplace-control"][resource] = nil

  for i, preset in pairs(map_gen_presets) do
    if(preset.basic_settings and preset.basic_settings.autoplace_controls) then
      preset.basic_settings.autoplace_controls[resource] = nil
    end
  end

  if fromResourceList then
    data.raw["resource"][resource] = nil
  end
end


RemoveResource("iron-ore", true)

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Remove Vanilla Ores

Post by Suf »

mpratt wrote:
Wed Jul 15, 2020 10:11 pm
Here's the function I use, it removes it from all the autoplace controls and then removes the resource itself:

Code: Select all

local function RemoveResource(resource, fromResourceList)
	local map_gen_presets = data.raw["map-gen-presets"]["default"]

  data.raw["autoplace-control"][resource] = nil

  for i, preset in pairs(map_gen_presets) do
    if(preset.basic_settings and preset.basic_settings.autoplace_controls) then
      preset.basic_settings.autoplace_controls[resource] = nil
    end
  end

  if fromResourceList then
    data.raw["resource"][resource] = nil
  end
end


RemoveResource("iron-ore", true)
Thanks for the help it worked :)

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: Remove Vanilla Ores

Post by Hiladdar »

All of the above recommendations are great. Here is one more. Take a look at what what other mod authors do in their mods, particulary look at how they code their mods. I say this because, to see how an existing mod performs a specific task, and how it works can be a great way to learn new way to do stuff, and new techniques.

Hiladdar

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Remove Vanilla Ores

Post by Suf »

Hiladdar wrote:
Fri Jul 17, 2020 5:58 pm
All of the above recommendations are great. Here is one more. Take a look at what what other mod authors do in their mods, particulary look at how they code their mods. I say this because, to see how an existing mod performs a specific task, and how it works can be a great way to learn new way to do stuff, and new techniques.

Hiladdar
Yeah I've checked multiple mods that use ores before posting this question;their structures are way different than the code above since most of them rely on other mods the author made,even though after i took all of that as reference (and changed some variables) it didn't work as the code above and it gave me many errors.
As you may guessed i'm lua noob here and i'm trying to understand the concept and change the codes to what i'm trying to achieve in my mod than just copy-paste without understanding anything,but apparently there's no updated lua tutorial for Factorio(visually) that does that for me,if you got anything similar to what i'm talking about then by all means tell me about it.

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: Remove Vanilla Ores

Post by Hiladdar »

Suf wrote:
Sat Jul 18, 2020 5:26 am
Hiladdar wrote:
Fri Jul 17, 2020 5:58 pm
All of the above recommendations are great. Here is one more. Take a look at what what other mod authors do in their mods, particulary look at how they code their mods. I say this because, to see how an existing mod performs a specific task, and how it works can be a great way to learn new way to do stuff, and new techniques.

Hiladdar
Yeah I've checked multiple mods that use ores before posting this question;their structures are way different than the code above since most of them rely on other mods the author made,even though after i took all of that as reference (and changed some variables) it didn't work as the code above and it gave me many errors.
As you may guessed i'm lua noob here and i'm trying to understand the concept and change the codes to what i'm trying to achieve in my mod than just copy-paste without understanding anything,but apparently there's no updated lua tutorial for Factorio(visually) that does that for me,if you got anything similar to what i'm talking about then by all means tell me about it.
Like you, when I started writing mods, I knew nothing about modding any game. I am just sharing one technique I used to learn how to mod this game, as well as learning from functional coding samples from a published mob. The other thing, that provided me was several different coding styles which work well with the lua language.

Hiladdar

Post Reply

Return to “Modding help”