If you load Factorio and open/start a map, you can see all the available prototypes by pressing "Ctrl-Shift-E". Select the "sprites" or "utility" category to see what is loaded.
The "sprite" and "sprite-button" gui elements can have their icon specified by anything listed in the
SpritePath defintion, which includes the "utility" category and the "technology" category. If you select a utility-sprite, it will appear by itself, with no other icons in the background.
The prototype of "utility-sprites" is not a normal sprite, but a giant list of sprites. If the sprite that you want is in the utility-sprites list, you can put it in the button (in its original state). The actual image files are located on your hard drive at "data/core/graphics/icons/technology/effect-constant/effect-constant-capacity.png".
Many of the utility-sprite images are used by the game to make overlays in the technology effects display, but these overlays are hardcoded. You cannot make composite icons at runtime that appear in sprite-button gui elements.
You can add new composite icons as standalone "sprite" prototypes in the data stage. You can use the same PNG files in your composite that are used in the utility sprites. You must reference the actual path of the PNG file. Based on "data/core/prototypes/utility-sprites.lua", the file path can be specified as "__core__/graphics/icons/technology/effect-constant/effect-constant-capacity.png" (for example, for the three-stacked-squares icon in your example).
(Technically, you could retrieve the file path from the data.raw["utility-sprites"]["character_logistic_trash_slots_modifier_constant"].filename, but it would have exactly the same effect and would be more cumbersome in my opinion.)
To actually make the composite sprite, you have to make a new sprite prototype with multiple layers, and then reference that sprite in your gui element. For example (see
Prototype/Sprite for all the other parameters):
Code: Select all
data.raw:extend( {
{
type = "sprite",
name = "my-character-capacity-sprite",
layers = {
{
filename = "__core__/graphics/icons/entity/character.png",
size = 64,
mipmap_count = 4,
},
{
filename = "__core__/graphics/icons/technology/effect-constant/effect-constant-capacity.png",
size = 64,
mipmap_count = 4,
}
}
}
} )
The second image in the list will be drawn on top of the first image in the list. The "tint" property can be used to make individual layers different colors or semi-transparent.
With this in your data.lua, the prototype viewer will show "my-character-capacity-sprite" in the "sprites" category. Setting the gui element "sprite" property to the string "my-character-capacity-sprite" will make it appear on the button.