Page 1 of 1

How to replace a graphic inside an array?

Posted: Sun Aug 16, 2020 5:56 pm
by MrFactorio
Hi,

I want to replace a graphic of a custom tank that has a list (or array) or 3 elements inside the layer element. The first one has the normal png file, the second the shadow and the third one the color mask png file.
How do I replace the first, the second and third element?

Does something like that work?

Code: Select all

data.raw.car["tank_name"].animation.layers[0].stripes.filename = "new path to base png"

Code: Select all

data.raw.car["tank_name"].animation.layers[1].stripes.filename = "new path to shadow png"

Code: Select all

data.raw.car["tank_name"].animation.layers[2].stripes.filename = "new path to mask png"
Thanks for your help!

Edit:

Ok this does not work. It says error in lua line 1 nil value.

Edit 2:
I could resolve all errors, but the graphics are still the same. I have now this line of code:

Code: Select all

data.raw.car["kr-advanced-tank"].animation.layers[1].stripes[1].filename = "__KrastorioTankGraphics__/graphics/entities/advanced-tank/advanced-tank-base.png"
I doublechecked the path which is correct. The mod in general works also because the remnant is correct replaced, it seems that I only dont know how to specify a special element in the array.

Re: How to replace a graphic inside an array?

Posted: Sun Aug 16, 2020 6:44 pm
by MrFactorio
Ok it works now!

Maybe as help for others... arrays start with 1 and not with 0 in lua :D.

Re: How to replace a graphic inside an array?

Posted: Mon Aug 17, 2020 10:26 am
by darkfrei
MrFactorio wrote: Sun Aug 16, 2020 6:44 pm Ok it works now!

Maybe as help for others... arrays start with 1 and not with 0 in lua :D.
Maybe useful for you.
viewtopic.php?t=45107