Page 1 of 1

How to just clone and modify and existing item

Posted: Sat Jun 25, 2016 3:05 pm
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!

Re: How to just clone and modify and existing item

Posted: Sat Jun 25, 2016 3:47 pm
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,
    }

Re: How to just clone and modify and existing item

Posted: Mon Jun 27, 2016 8:23 am
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.

Re: How to just clone and modify and existing item

Posted: Sat Aug 06, 2016 2:16 am
by weareryan
Wow this is handy and did not know you could do it this way.