Modifying vanilla components help

Place to get help with not working mods / modding interface.
graystripedkitty
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Aug 21, 2020 6:36 pm
Contact:

Modifying vanilla components help

Post by graystripedkitty »

I only have a little experience with coding, and none with Lua. I would like to make a mod that is purely cosmetic that would change the appearance of enemies as well as slightly modify existing sprites for worldgen. I don't want to change gameplay at all. How do I tell the game to use my sprites instead of the originals? In short, I can't figure out how to change the attributes of vanilla components instead of creating a new component like many tutorials show you how to do. I am probably missing something completely obvious due to my inexperience. I would also appreciate recommendations for good beginner tutorials. Thanks!
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Modifying vanilla components help

Post by DaveMcW »

You picked a hard task, enemies are very complex.

First, you need to create a mod folder, an info.json, and a data.lua. See the Modding tutorial to create them from scratch or just edit any other mod.

To change an enemy's sprite, put this in data.lua. Change my-mod to the name of your mod.

Code: Select all

data.raw['unit']['small-biter'].run_animation.layers[1].filenames[1] = "__my-mod__/graphics/biter-run-01.png
data.raw['unit']['small-biter'].run_animation.layers[1].filenames[2] = "__my-mod__/graphics/biter-run-02.png
data.raw['unit']['small-biter'].run_animation.layers[1].filenames[3] = "__my-mod__/graphics/biter-run-03.png
data.raw['unit']['small-biter'].run_animation.layers[1].filenames[4] = "__my-mod__/graphics/biter-run-04.png
data.raw['unit']['small-biter'].run_animation.layers[1].hr_version.filenames[1] = "__my-mod__/graphics/hr-biter-run-01.png
data.raw['unit']['small-biter'].run_animation.layers[1].hr_version.filenames[2] = "__my-mod__/graphics/hr-biter-run-02.png
data.raw['unit']['small-biter'].run_animation.layers[1].hr_version.filenames[3] = "__my-mod__/graphics/hr-biter-run-03.png
data.raw['unit']['small-biter'].run_animation.layers[1].hr_version.filenames[4] = "__my-mod__/graphics/hr-biter-run-04.png
Then you need to create a folder called "graphics" in your mod folder. Copy the 8 png files from the base game, edit them, and put them in your graphics folder.

If you did everything correctly, small biters will now use your edited run animation. But there are a bunch of other sprites for color mask, shadow, attack animation, death, icon, etc. And then there are custom sprite dimensions if you don't want to use the base game images as a template. See the data.raw dump for an exhaustive example of everything you can use.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Modifying vanilla components help

Post by darkfrei »

graystripedkitty wrote: Fri Aug 21, 2020 7:20 pm I only have a little experience with coding, and none with Lua. I would like to make a mod that is purely cosmetic that would change the appearance of enemies as well as slightly modify existing sprites for worldgen.
Such as Ball Biters?

You can use also this mod for better understanding: viewtopic.php?t=45107
graystripedkitty
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Aug 21, 2020 6:36 pm
Contact:

Re: Modifying vanilla components help

Post by graystripedkitty »

That is really helpful; thanks! One more question: do I need to have the same number of frames in the animation or will it adapt based on the pre-set frame size? (I have no intention of changing any sizes.)

Ball biters is a perfect example of the sort of thing I want to do; thanks for pointing it out!
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Modifying vanilla components help

Post by darkfrei »

graystripedkitty wrote: Sun Aug 23, 2020 2:02 pm That is really helpful; thanks! One more question: do I need to have the same number of frames in the animation or will it adapt based on the pre-set frame size? (I have no intention of changing any sizes.)

Ball biters is a perfect example of the sort of thing I want to do; thanks for pointing it out!
2020-08-23T16_35_42.png
2020-08-23T16_35_42.png (49.69 KiB) Viewed 885 times
You are need to adjust sprite sizes and sprite sheep properties.

Here:
1. Every sprite is 182x176 pixels;
2. there is 4 spritesheets;
3. every spritesheet is 11 sprites wide, one line is one animation cycle, 4 sprites high;
4. 4 files, each with 4 directions = 16 directions.
Post Reply

Return to “Modding help”