Page 1 of 1
Modifying vanilla components help
Posted: Fri Aug 21, 2020 7:20 pm
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!
Re: Modifying vanilla components help
Posted: Fri Aug 21, 2020 8:24 pm
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.
Re: Modifying vanilla components help
Posted: Fri Aug 21, 2020 8:56 pm
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
Re: Modifying vanilla components help
Posted: Sun Aug 23, 2020 2:02 pm
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!
Re: Modifying vanilla components help
Posted: Sun Aug 23, 2020 2:37 pm
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 (49.69 KiB) Viewed 1000 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.