How to just clone and modify and existing item

Place to post guides, observations, things related to modding that are not mods themselves.
Lepo
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Jun 25, 2016 3:00 pm
Contact:

How to just clone and modify and existing item

Post by Lepo »

Hello, i just want to make a simple mod that adds new things like a new inserter or a new engine.
To do this i just want to clone existing items in vanilla and then tweak stats and graphic.
Anyone can make me a small example mod for i don't know a "faster" fast inserter?
Thank you very much!
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: How to just clone and modify and existing item

Post by Adil »

Code: Select all

require 'util'

new_ent=table.deepcopy (data.raw.inserter['basic-inserter'])

--basically you look at original prototype definition and put whatever fields you want different in your definition
new_ent.name='not-basic-inserter'

new_ent.rotation_speed=0.08

table.insert(new_ent.resistances,{type='physical',percent=80})

new_ent.hand_base_picture={
    filename='__core__/graphics/empty.png',
    priority='normal',
    width=1,
    height = 1,
    }
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: How to just clone and modify and existing item

Post by bobingabout »

and don't forget that once you've setup new_ent as "not-basic-inseter" (Fairly sure it does have to be the double quote to denote strings) you'll need to actually put it in the game, which is simple

Code: Select all

data:extend(
  new_ent
)
you'll also need to set up new items and recipes etc too, along with any technologies to unlock them.


Personally though, I copy the entire code of an entity when redefining it, then make my changes to that, but it does have the drawback that when the original changes (Like adding circuit wire nodes) that you have to manually go and add them afterwards. in the case of the entity copying system mentioned above, all that would be done for you automatically when the original updates.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
weareryan
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Jul 31, 2016 5:17 pm
Contact:

Re: How to just clone and modify and existing item

Post by weareryan »

Wow this is handy and did not know you could do it this way.
Post Reply

Return to “Modding discussion”