Prototype/Sprite: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(0.17)
m (Example didn't have type defined)
Line 168: Line 168:
== Example ==
== Example ==
     {
     {
      type = "sprite"
       name = "accumulator-sprite",
       name = "accumulator-sprite",
       filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",
       filename = "__base__/graphics/entity/basic-accumulator/basic-accumulator.png",

Revision as of 12:13, 28 May 2019

Basics

Prototype type: sprite

Specifies a picture that can be used with https://lua-api.factorio.com/latest/Concepts.html#SpritePath during runtime.

Mandatory properties

type

Type: Types/string

Must be "sprite".

name

Type: Types/string

Name of the sprite. Must be unique. Used in https://lua-api.factorio.com/latest/Concepts.html#SpritePath.

filename

Type: Types/FileName

Default: ""

Technically optional, but path to sprite cannot be empty.

Optional properties

layers

Type: Types/table of Types/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. Each item (Sprite definition) in the array may also have the layers property.

If this property is present, all other properties are ignored and the mandatory properties do not have to be defined.

hr_version

Type: Types/Sprite

If this property exists and high resolution sprites are turned on, its contents are used to load the sprite.

slice

Type: Types/SpriteSizeType

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.

Example: If this is 4, the sprite will be sliced into a 4×4 grid.

slice_x

Type: Types/SpriteSizeType

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

slice_y

Type: Types/SpriteSizeType

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

priority

Type: Types/string

Default: "medium"

Possible values:

  • "extra-high-no-scale"
  • "extra-high"
  • "high"
  • "medium"
  • "low"
  • "very-low"

flags

Type: Types/SpriteFlags

size

Type: Types/SpriteSizeType or Types/table of Types/SpriteSizeType

The width and height of the sprite. If this is an array, the first member of the array 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

Type: Types/SpriteSizeType

Mandatory if size is not given. Width of the picture in pixels, from 0-8192.

height

Type: Types/SpriteSizeType

Mandatory if size is not given. Height of the picture in pixels, from 0-8192.

x

Type: Types/SpriteSizeType

Default: 0

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

y

Type: Types/SpriteSizeType

Default: 0

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

position

Type: Types/table of Types/SpriteSizeType

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

shift

Type: Types/vector

Default: {0, 0}

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

Type: Types/double

Default: 1

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

draw_as_shadow

Type: Types/bool

Default: false

apply_runtime_tint

Type: Types/bool

Default: false

tint

Type: Types/Color

Default: {r=1, g=1, b=1, a=1} (white)

blend_mode

Type: Types/string

Default: "normal"

Possible values:

  • "normal"
  • "additive"
  • "additive-soft"
  • "multiplicative"
  • "overwrite"

load_in_minimal_mode

Type: Types/bool

Default: false

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). If you are a modder, you can just ignore this property.

premul_alpha

Type: Types/bool

Default: true

Whether alpha should be premultiplied.

generate_sdf

Type: Types/bool

Default: false

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}
   }