Modifying vanilla components help
-
- Manual Inserter
- Posts: 2
- Joined: Fri Aug 21, 2020 6:36 pm
- Contact:
Modifying vanilla components help
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
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.
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.
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
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
Such as Ball Biters?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.
You can use also this mod for better understanding: viewtopic.php?t=45107
-
- Manual Inserter
- Posts: 2
- Joined: Fri Aug 21, 2020 6:36 pm
- Contact:
Re: Modifying vanilla components help
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!
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
You are need to adjust sprite sizes and sprite sheep properties.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!
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.