Factorio Prototype DocsVersion 1.1.107

SpritePrototype - 'sprite' Example code

Specifies an image that can be used with SpritePath at runtime.

Properties

type :: "sprite"
name :: string

Name of the sprite. [...]

Name of the sprite. [...]

layers optional :: array[Sprite]

If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. [...]

If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. [...]

filename optional :: FileName

Only loaded, and mandatory if layers is not defined. [...]

Only loaded, and mandatory if layers is not defined. [...]

hr_version optional :: Sprite

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

slice or dice optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

slice_x or dice_x optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

slice_y or dice_y optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

priority optional :: SpritePriority

Only loaded if layers is not defined.

Only loaded if layers is not defined.

flags optional :: SpriteFlags

Only loaded if layers is not defined.

Only loaded if layers is not defined.

size optional :: SpriteSizeType or {SpriteSizeType, SpriteSizeType}

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

width optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

height optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

x optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

y optional :: SpriteSizeType

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

position optional :: {SpriteSizeType, SpriteSizeType}

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

shift optional :: Vector

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

scale optional :: double

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

draw_as_shadow optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

draw_as_glow optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

draw_as_light optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

mipmap_count optional :: uint8

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

apply_runtime_tint optional :: bool

Only loaded if layers is not defined.

Only loaded if layers is not defined.

tint optional :: Color

Only loaded if layers is not defined.

Only loaded if layers is not defined.

blend_mode optional :: BlendMode

Only loaded if layers is not defined.

Only loaded if layers is not defined.

load_in_minimal_mode optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

premul_alpha optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

generate_sdf optional :: bool

Only loaded if layers is not defined. [...]

Only loaded if layers is not defined. [...]

Properties

type :: "sprite"

name :: string

Name of the sprite. Can be used as a SpritePath at runtime.

layers :: array[Sprite] optional

If this property is present, all Sprite definitions have to be placed as entries in the array, and they will all be loaded from there. layers may not be an empty table. Each definition in the array may also have the layers property.

If this property is present, all other properties besides name and type are ignored.

filename :: FileName optional

Only loaded, and mandatory if layers is not defined.

The path to the sprite file to use.

hr_version :: Sprite optional

Only loaded if layers is not defined.

If this property exists and high resolution sprites are turned on, this is used to load the Sprite.

slice or dice :: SpriteSizeType optional

Only loaded if layers is not defined.

Number of slices this is sliced into when using the "optimized atlas packing" option. If you are a modder, you can just ignore this property. As an example, if this is 4, the sprite will be sliced into a 4x4 grid.

slice_x or dice_x :: SpriteSizeType optional

Only loaded if layers is not defined.

Same as slice, but this specifies only how many slices there are on the x-axis.

slice_y or dice_y :: SpriteSizeType optional

Only loaded if layers is not defined.

Same as slice, but this specifies only how many slices there are on the y-axis.

priority :: SpritePriority optional

Default: "medium"

Only loaded if layers is not defined.

flags :: SpriteFlags optional

Only loaded if layers is not defined.

size :: SpriteSizeType or {SpriteSizeType, SpriteSizeType} optional

Only loaded if layers is not defined.

The width and height of the sprite. If this is a tuple, the first member of the tuple is the width and the second is the height. Otherwise the size is both width and height. Width and height may only be in the range of 0-8192.

width :: SpriteSizeType optional

Only loaded if layers is not defined. Mandatory if size is not defined.

Width of the picture in pixels, from 0-8192.

height :: SpriteSizeType optional

Only loaded if layers is not defined. Mandatory if size is not defined.

Height of the picture in pixels, from 0-8192.

x :: SpriteSizeType optional

Default: 0

Only loaded if layers is not defined.

Horizontal position of the sprite in the source file in pixels.

y :: SpriteSizeType optional

Default: 0

Only loaded if layers is not defined.

Vertical position of the sprite in the source file in pixels.

position :: {SpriteSizeType, SpriteSizeType} optional

Only loaded if layers is not defined.

Loaded only when x and y are both 0. The first member of the tuple is x and the second is y.

shift :: Vector optional

Default: {0, 0}

Only loaded if layers is not defined.

The shift in tiles. util.by_pixel() can be used to divide the shift by 32 which is the usual pixel height/width of 1 tile in normal resolution. Note that 32 pixel tile height/width is not enforced anywhere - any other tile height or width is also possible.

scale :: double optional

Default: 1

Only loaded if layers is not defined.

Values other than 1 specify the scale of the sprite on default zoom. A scale of 2 means that the picture will be two times bigger on screen (and thus more pixelated).

draw_as_shadow :: bool optional

Default: false

Only loaded if layers is not defined.

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. This takes precedence over draw_as_glow and draw_as_light.

draw_as_glow :: bool optional

Default: false

Only loaded if layers is not defined.

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. This takes precedence over draw_as_light.

Draws first as a normal sprite, then again as a light layer. See https://forums.factorio.com/91682.

draw_as_light :: bool optional

Default: false

Only loaded if layers is not defined.

Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true.

mipmap_count :: uint8 optional

Default: 0

Only loaded if layers is not defined.

Only loaded if this is an icon, that is it has the flag "group=icon" or "group=gui".

apply_runtime_tint :: bool optional

Default: false

Only loaded if layers is not defined.

tint :: Color optional

Default: {r=1, g=1, b=1, a=1}

Only loaded if layers is not defined.

blend_mode :: BlendMode optional

Default: "normal"

Only loaded if layers is not defined.

load_in_minimal_mode :: bool optional

Default: false

Only loaded if layers is not defined.

Minimal mode is entered when mod loading fails. You are in it when you see the gray box after (part of) the loading screen that tells you a mod error (Example). Modders can ignore this property.

premul_alpha :: bool optional

Default: true

Only loaded if layers is not defined.

Whether alpha should be pre-multiplied.

generate_sdf :: bool optional

Default: false

Only loaded if layers is not defined.

Unused.

Example

{
  type = "sprite"
  name = "accumulator-sprite",
  filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",
  priority = "extra-high",
  width = 124,
  height = 103,
  shift = {0.7, -0.2}
}

Prototypes

Types