Prototype/Sprite: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(fixed mipmap count description)
(Removed old prototype docs)
Tag: Replaced
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Prototype parent}}
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/SpritePrototype.html https://lua-api.factorio.com/latest/prototypes/SpritePrototype.html]
Specifies a picture that can be used with https://lua-api.factorio.com/latest/Concepts.html#SpritePath during runtime.


{{Prototype TOC|sprite}}
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
== Mandatory properties ==
 
{{Prototype property|type|[[Types/string|string]]}}
Must be "sprite".
 
{{Prototype property|name|[[Types/string|string]]}}
Name of the sprite. Must be unique. Can be used as a https://lua-api.factorio.com/latest/Concepts.html#SpritePath.
 
{{Prototype property|filename|[[Types/FileName|FileName]]|""}}
Technically optional, but path to sprite cannot be empty.
 
== Optional properties ==
 
{{Prototype property|layers|[[Types/table|table]] of [[Types/Sprite|Sprite]]|optional=true}}
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 <code>layers</code> 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.
 
{{Prototype property|hr_version|[[Types/Sprite|Sprite]]|optional=true}}
If this property exists and high resolution sprites are turned on, its contents are used to load the sprite.
 
{{Prototype property|slice|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
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.
 
{{Prototype property|slice_x|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
Same as <code>slice</code> above, but this specifies only how many slices there are on the x axis.
 
{{Prototype property|slice_y|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
Same as <code>slice</code> above, but this specifies only how many slices there are on the y axis.
 
{{Prototype property|priority|[[Types/string|string]]|"medium"|optional=true}}
Possible values:
* "extra-high-no-scale"
* "extra-high"
* "high"
* "medium"
* "low"
* "very-low"
 
{{Prototype property|flags|[[Types/SpriteFlags|SpriteFlags]]||optional=true}}
 
{{Prototype property|size|[[Types/SpriteSizeType|SpriteSizeType]] or [[Types/table|table]] of [[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
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.
 
{{Prototype property|width|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
Mandatory if <code>size</code> is not given. Width of the picture in pixels, from 0-8192.
 
{{Prototype property|height|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
Mandatory if <code>size</code> is not given. Height of the picture in pixels, from 0-8192.
 
{{Prototype property|x|[[Types/SpriteSizeType|SpriteSizeType]]|0|optional=true}}
Horizontal position of the sprite in the source file in pixels.
 
{{Prototype property|y|[[Types/SpriteSizeType|SpriteSizeType]]|0|optional=true}}
Vertical position of the sprite in the source file in pixels.
 
{{Prototype property|position|[[Types/table|table]] of [[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
Loaded only when <code>x</code> and <code>y</code> are both 0. The first member of the array is x and the second is y.
 
{{Prototype property|shift|[[Types/vector|vector]]|<nowiki>{0, 0}</nowiki>|optional=true}}
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.
 
{{Prototype property|scale|[[Types/double|double]]|1|optional=true}}
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).
 
{{Prototype property|draw_as_shadow|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|mipmap_count|[[Types/uint8|uint8]]|0|optional=true}}
Only loaded if this is an icon (has flag "group=icon" or "group=gui").
 
{{Prototype property|apply_runtime_tint|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|tint|[[Types/Color|Color]]|<nowiki>{r=1, g=1, b=1, a=1} (white)</nowiki>|optional=true}}
 
{{Prototype property|blend_mode|[[Types/string|string]]|"normal"|optional=true}}
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 <code>premul_alpha</code> is set to false, Active_RGB is considered to be premultiplied with alpha.
 
{{Prototype property|load_in_minimal_mode|[[Types/bool|bool]]|false|optional=true}}
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 ([https://cdn.discordapp.com/attachments/340530709712076801/532315796626472972/unknown.png Example]). If you are a modder, you can just ignore this property.
 
{{Prototype property|premul_alpha|[[Types/bool|bool]]|true|optional=true}}
Whether alpha should be premultiplied.
 
{{Prototype property|generate_sdf|[[Types/bool|bool]]|false|optional=true}}
 
== 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}
    }

Latest revision as of 14:33, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/prototypes/SpritePrototype.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.