How do you replace component of the base mod?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Solar's Wrath
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 8:09 pm
Contact:

How do you replace component of the base mod?

Post by Solar's Wrath »

I am working on a mod, I have very basic modding knowledge for now so this isn't something I know but How do you replace a Base item or building for something else? Or just make it so certain Base stuff are ignored?

Exemple I want to replace Iron by something else and I want to replace Science labs by another building.

That would really help thanks ^^
Last edited by Solar's Wrath on Mon Sep 05, 2016 2:17 pm, edited 1 time in total.

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

Re: How to replace an item/building for another

Post by aubergine18 »

Depends when you want to do it... If you want the change to apply globally, then do it via prototypes - take a look at "balance" mods in the mod portal, unzip them and look in the prototypes folder.

If you want to do it in-game, on specific things on an ad-hoc basis, then you'd have to get a reference to the entity, or whatever, and destroy it then replace it with the new thing.

In either case, I'd suggest looking for mods that do similar changes to what you want and then look at how they do it.
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.

User avatar
Solar's Wrath
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 8:09 pm
Contact:

Re: How to replace an item/building for another

Post by Solar's Wrath »

What I mean is like, my mod would remove certain stuff from the Base mod, it would just not be in the game at all and be replaced by my new object/building

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 339
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: How to replace an item/building for another

Post by LuziferSenpai »

Solar's Wrath wrote:What I mean is like, my mod would remove certain stuff from the Base mod, it would just not be in the game at all and be replaced by my new object/building
You mean from Raw Factory right?

If you want that you need to nil it.
But becareful with it!
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
Solar's Wrath
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 8:09 pm
Contact:

Re: How to replace an item/building for another

Post by Solar's Wrath »

LuziferSenpai wrote:
Solar's Wrath wrote: If you want that you need to nil it.
But how do you do that? I know how to add stuff but I don't know how to nil stuff. Its kinda my problem at the moment ^^'

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

Re: How do you replace component of the base mod?

Post by aubergine18 »

Look in existing mods for anything that alters data.raw, especially in data-final-fixes.lua. The data.raw contains all the prototypes from all the mods, and you can edit, add, delete, stuff in it.
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.

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 339
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: How do you replace component of the base mod?

Post by LuziferSenpai »

This is a older way how i did it.

Code: Select all

data.raw["item"][name] = nil
data.raw["recipe"][name] = nil
or

Code: Select all

data.raw["item"][name] = nil
data.raw['active-defense-equipment'][name] = nil
data.raw["recipe"][name] = nil

data.raw['active-defense-equipment']["basic-electric-discharge-defense-equipment"] = nil
data.raw["capsule"]["basic-electric-discharge-defense-remote"] = nil
data.raw["recipe"]["basic-electric-discharge-defense-remote"] = nil
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
Solar's Wrath
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 8:09 pm
Contact:

Re: How do you replace component of the base mod?

Post by Solar's Wrath »

aubergine18 wrote:Look in existing mods for anything that alters data.raw, especially in data-final-fixes.lua. The data.raw contains all the prototypes from all the mods, and you can edit, add, delete, stuff in it.
Where is data-final-fixes.lua?
And what is data.raw?

LuziferSenpai
Thanks and if I just want to change the texture of an existing item or the sprite of a building for something else?

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 339
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: How do you replace component of the base mod?

Post by LuziferSenpai »

Solar's Wrath wrote:
aubergine18 wrote:Look in existing mods for anything that alters data.raw, especially in data-final-fixes.lua. The data.raw contains all the prototypes from all the mods, and you can edit, add, delete, stuff in it.
Where is data-final-fixes.lua?
And what is data.raw?

LuziferSenpai
Thanks and if I just want to change the texture of an existing item or the sprite of a building for something else?
Look for that in my Senpais Overhall MOD in the data-final-fixes. There you see how i did it.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
Solar's Wrath
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 8:09 pm
Contact:

Re: How do you replace component of the base mod?

Post by Solar's Wrath »

LuziferSenpai wrote: Look for that in my Senpais Overhall MOD in the data-final-fixes. There you see how i did it.
Thanks I'm gonna look this up ^^

Post Reply

Return to “Modding help”