Prototype/Sprite: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (whitespace)
(0.18.19: Layers may not be an empty table.)
Line 21: Line 21:


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


{{Prototype property|hr_version|[[Types/Sprite|Sprite]]|optional=true}}
{{Prototype property|hr_version|[[Types/Sprite|Sprite]]|optional=true}}

Revision as of 17:12, 22 April 2020

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

Template:Prototype TOC

Mandatory properties

Template:Prototype property Must be "sprite".

Template:Prototype property Name of the sprite. Must be unique. Can be used as a https://lua-api.factorio.com/latest/Concepts.html#SpritePath.

Template:Prototype property Technically optional, but path to sprite cannot be empty.

Optional properties

Template:Prototype property 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.

Layers may not be an empty table.

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

Template:Prototype property 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.

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

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

Template:Prototype property Possible values:

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

Template:Prototype property

Template:Prototype property 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.

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

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

Template:Prototype property Horizontal position of the sprite in the source file in pixels.

Template:Prototype property Vertical position of the sprite in the source file in pixels.

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

Template:Prototype property 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.

Template:Prototype property 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).

Template:Prototype property

Template:Prototype property Only loaded if this is an icon (has flag "icon").

Template:Prototype property

Template:Prototype property

Template:Prototype property Possible values:

  • "normal" -- Result = Active_RGB * Active_Alpha + Background_RGB * ( 1 - Active_Alpha )
  • "additive" -- Result = Active_RGB + Background_RGB
  • "additive-soft" -- Result = Active_RGB * ( 1 - Background_RGB ) + Background_RGB
  • "multiplicative" -- Result = Active_RGB * Background_RGB
  • "overwrite" -- Result = Active_RGBA or Background_RGBA

Note: Unless premul_alpha is set to false, Active_RGB is considered to be premultiplied with alpha.

Template:Prototype property 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.

Template:Prototype property Whether alpha should be premultiplied.

Template:Prototype property

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