Page 1 of 1

Remove Vanilla Ores

Posted: Fri Jul 10, 2020 5:22 am
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.

Re: Remove Vanilla Ores

Posted: Fri Jul 10, 2020 8:44 am
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

Re: Remove Vanilla Ores

Posted: Fri Jul 10, 2020 10:46 am
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?

Re: Remove Vanilla Ores

Posted: Fri Jul 10, 2020 11:24 am
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

Re: Remove Vanilla Ores

Posted: Fri Jul 10, 2020 12:05 pm
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

Re: Remove Vanilla Ores

Posted: Wed Jul 15, 2020 10:11 pm
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)

Re: Remove Vanilla Ores

Posted: Fri Jul 17, 2020 10:27 am
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 :)

Re: Remove Vanilla Ores

Posted: Fri Jul 17, 2020 5:58 pm
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

Re: Remove Vanilla Ores

Posted: Sat Jul 18, 2020 5:26 am
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.

Re: Remove Vanilla Ores

Posted: Sat Jul 18, 2020 7:32 pm
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