Page 1 of 1

Edit an exsisting machine

Posted: Mon May 02, 2016 5:55 pm
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

Re: Edit an exsisting machine

Posted: Mon May 02, 2016 7:15 pm
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
}

Re: Edit an exsisting machine

Posted: Mon May 02, 2016 10:13 pm
by kasandraen
I---Feel stupid haha Thanks!!

Re: Edit an exsisting machine

Posted: Tue May 03, 2016 8:04 am
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.