Edit an exsisting machine

Place to get help with not working mods / modding interface.
kasandraen
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Wed May 27, 2015 11:00 pm
Contact:

Edit an exsisting machine

Post by kasandraen »

Hi

I'm trying to edit the base assembly machine to move the exsisting fluid box. I know how to add more, but I dont understand how to edit an exsisting one / delete all the old one and make new ones?

To add I'm using : (copied from dytech-core!)
table.insert(data.raw["assembling-machine"]["assembling-machine-2"].fluid_boxes,{
production_type = "input",
pipe_picture = assembler2pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 100,
base_level = -1,
pipe_connections = {{ type="input", position = {2, 0} }}
})
But I need to have 4 liquid boxes so I'm trying to add 2 on the bottom instead of the default 1. And to do that I need to have them 1 space apart.
So the default boxes after my edit need to be
{
{
production_type = "input",
pipe_picture = assembler3pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 10,
base_level = -1,
pipe_connections = {{ type="input", position = {1, -2} }}
},
{
production_type = "input",
pipe_picture = assembler3pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 10,
base_level = -1,
pipe_connections = {{ type="input", position = {-1, -2} }}
},
{
production_type = "output",
pipe_picture = assembler3pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 10,
base_level = 1,
pipe_connections = {{ type="output", position = {0, 2} }}
},
off_when_no_fluid_recipe = true
},
This is how I want it to be Image
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Edit an exsisting machine

Post by DaveMcW »

kasandraen wrote:I dont understand how to edit an exsisting one / delete all the old one and make new ones?
If you set it directly instead of using table.insert(), you will overwrite the old ones.

Code: Select all

data.raw["assembling-machine"]["assembling-machine-2"].fluid_boxes = {
  {
    production_type = "input",
    pipe_picture = assembler2pipepictures(),
    pipe_covers = pipecoverspictures(),
    base_area = 10,
    base_level = -1,
    pipe_connections = {{ type="input", position = {-2, 0} }}
  },
  {
    production_type = "input",
    pipe_picture = assembler2pipepictures(),
    pipe_covers = pipecoverspictures(),
    base_area = 10,
    base_level = -1,
    pipe_connections = {{ type="input", position = {2, 0} }}
  },
  {
    production_type = "input",
    pipe_picture = assembler3pipepictures(),
    pipe_covers = pipecoverspictures(),
    base_area = 10,
    base_level = -1,
    pipe_connections = {{ type="input", position = {1, -2} }}
  },
  {
    production_type = "input",
    pipe_picture = assembler3pipepictures(),
    pipe_covers = pipecoverspictures(),
    base_area = 10,
    base_level = -1,
    pipe_connections = {{ type="input", position = {-1, -2} }}
  },
  {
    production_type = "output",
    pipe_picture = assembler3pipepictures(),
    pipe_covers = pipecoverspictures(),
    base_area = 10,
    base_level = 1,
    pipe_connections = {{ type="output", position = {0, 2} }}
  },
  off_when_no_fluid_recipe = true
}
kasandraen
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Wed May 27, 2015 11:00 pm
Contact:

Re: Edit an exsisting machine

Post by kasandraen »

I---Feel stupid haha Thanks!!
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Edit an exsisting machine

Post by bobingabout »

Just keep in mind that editing an existing entity in such a way will break existing layouts. if you want to make such major modifications, I would usually recommend you create a cloned entity, with a new purpose.

The example above also replaces all fluid boxes, there are alternate methods to edit the existing ones, and then add the rest, but they start looking pretty complex, what is there will work, and is fairly safe to use. I don't see it causing issues even if someone else tries to edit the entity after you.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”