What does factorio do with unused sprites?

Place to get help with not working mods / modding interface.
raspberrypuppies
Inserter
Inserter
Posts: 48
Joined: Tue Mar 26, 2019 4:43 am
Contact:

What does factorio do with unused sprites?

Post 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?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: What does factorio do with unused sprites?

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15967
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: What does factorio do with unused sprites?

Post 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).
If you want to get ahold of me I'm almost always on Discord.
raspberrypuppies
Inserter
Inserter
Posts: 48
Joined: Tue Mar 26, 2019 4:43 am
Contact:

Re: What does factorio do with unused sprites?

Post by raspberrypuppies »

Thanks for the help! This should make my life a lot easier. I was dreading thinking about managing dozens of tiny mods.
Post Reply

Return to “Modding help”