Page 1 of 1

What does factorio do with unused sprites?

Posted: Tue May 26, 2020 12:11 am
by raspberrypuppies
I'm trying to make a sprite pack mod that other mods can use. I don't want to create any entities, just provide art. This means there's a good chance that some of the assets would go unused if someone actually imports it as a dependency. Does anyone know what Factorio does with textures that are in the mod but aren't actually referenced by any entities?

I can think of a few possibilities:
a) It loads everything into memory assuming that the texture will be referenced at run-time via scripting logic
b) It checks that the sprite exists and maybe stores checksums or something to a database but doesn't fully load it
c) It only loads sprites that it actually referenced by entities in the game

I'd prefer anything but a) because that makes things easier for me. If it does a) then I should break each sprite pack into entity-specific mods. So "gun-turret-1-sprites" and "gun-turret-2-sprites" would each be their own mods. That sounds like a huge pain to deal with. Does anyone know off-hand how it works before I try to prematurely optimize it?

Re: What does factorio do with unused sprites?

Posted: Tue May 26, 2020 12:40 am
by DaveMcW
Don't use the word "sprite". It has a specific meaning in Factorio mods. A sprite is an image loaded into graphic memory to make it very fast for ingame use.

The answer is c. If your mod does not have a data.lua file that defines entities, it will not use memory.

Re: What does factorio do with unused sprites?

Posted: Tue May 26, 2020 1:08 am
by Rseding91
The answer is "C" provided you aren't referencing the image through something like what was linked (type 'sprite' is a thing which forces the game to load it so mods can use it runtime optionally).

Re: What does factorio do with unused sprites?

Posted: Tue May 26, 2020 1:12 am
by raspberrypuppies
Thanks for the help! This should make my life a lot easier. I was dreading thinking about managing dozens of tiny mods.