How to replace a graphic inside an array?

Place to get help with not working mods / modding interface.
Post Reply
MrFactorio
Inserter
Inserter
Posts: 30
Joined: Tue Nov 13, 2018 4:50 pm
Contact:

How to replace a graphic inside an array?

Post 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.

MrFactorio
Inserter
Inserter
Posts: 30
Joined: Tue Nov 13, 2018 4:50 pm
Contact:

Re: How to replace a graphic inside an array?

Post by MrFactorio »

Ok it works now!

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

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to replace a graphic inside an array?

Post 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

Post Reply

Return to “Modding help”