Types/RotatedSprite: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(0.18.19: Layers may not be an empty table.)
(Removed old prototype docs)
Tag: Replaced
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Basics ==
<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/types/RotatedSprite.html https://lua-api.factorio.com/latest/types/RotatedSprite.html]
Specifies series of sprites used to visualise different rotations of the object.


== Mandatory properties ==
</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>
 
=== direction_count ===
'''Type''': [[Types/uint16]]
 
Count of direction (frames) specified.
 
== Optional properties ==
 
=== filename ===
'''Type''': [[Types/FileName]]
 
'''Default''': ""
 
Either this or <code>"filenames"</code> has to be non-empty.
 
=== filenames ===
'''Type''': [[types/table]] of [[Types/FileName]]
 
'''Default''': ""
 
Array of filenames. Either this or <code>"filename"</code> has to be non-empty.
 
=== layers ===
'''Type''': [[Types/table]] of [[Types/RotatedSprite]]
 
If this property is present, all RotatedSprite definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (RotatedSprite 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.
 
=== hr_version ===
'''Type''': [[Types/RotatedSprite]]
 
If this property exists and high resolution sprites are turned on, its contents are used to load the RotatedSprite.
 
=== 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 <code>slice</code> above, but this specifies only how many slices there are on the x axis.
 
=== slice_y ===
'''Type''': [[Types/SpriteSizeType]]
 
Same as <code>slice</code> 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 <code>size</code> is not given. Width of the picture in pixels, from 0-8192.
 
=== height ===
'''Type''': [[Types/SpriteSizeType]]
 
Mandatory if <code>size</code> 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 <code>x</code> and <code>y</code> 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
 
=== mipmap_count ===
'''Type''': [[Types/uint8]]
 
'''Default''': 0
 
Only loaded if this is an icon (has flag "icon").
 
=== 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"          ''-- 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.
 
=== 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 ([https://cdn.discordapp.com/attachments/340530709712076801/532315796626472972/unknown.png 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
 
=== axially_symmetrical ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
When set to true, left the same picture is used for left/right direction, just flipped, this can save half of the space required, but is not usable once the picture contains shadows etc.
 
=== back_equals_front ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
=== apply_projection ===
'''Type''': [[Types/bool]]
 
'''Default''': true
 
Used to fix the inconsistency of direction of the entity in 3d when rendered and direction on the screen (where the 45 degree angle for projection is used).
 
=== line_length ===
'''Type''': [[Types/uint32]]
 
'''Defult''': 0
 
Used to specify the individual images in grid.
0 means that all the picture are in one horizontal line.
 
=== allow_low_quality_rotation ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
=== lines_per_file ===
'''Type''': [[Types/uint64]]
 
Mandatory if <code>"filenames"</code> exists.
 
== Example ==
<syntaxhighlight lang="lua">pictures =
    {
      layers =
      {
        {
          filename = "__base__/graphics/entity/radar/radar.png",
          priority = "low",
          width = 98,
          height = 128,
          apply_projection = false,
          direction_count = 64,
          line_length = 8,
          shift = util.by_pixel(1, -16),
          hr_version =
          {
            filename = "__base__/graphics/entity/radar/hr-radar.png",
            priority = "low",
            width = 196,
            height = 254,
            apply_projection = false,
            direction_count = 64,
            line_length = 8,
            shift = util.by_pixel(1, -16),
            scale = 0.5
          }
        },
        {
          filename = "__base__/graphics/entity/radar/radar-shadow.png",
          priority = "low",
          width = 172,
          height = 94,
          apply_projection = false,
          direction_count = 64,
          line_length = 8,
          shift = util.by_pixel(39,3),
          draw_as_shadow = true,
          hr_version =
          {
            filename = "__base__/graphics/entity/radar/hr-radar-shadow.png",
            priority = "low",
            width = 343,
            height = 186,
            apply_projection = false,
            direction_count = 64,
            line_length = 8,
            shift = util.by_pixel(39.25,3),
            draw_as_shadow = true,
            scale = 0.5
          }
        }
      }
    },</syntaxhighlight>
 
{{Prototype property type usage|{{FULLPAGENAME}}}}

Latest revision as of 14:32, 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/types/RotatedSprite.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.