Prototype/Animation: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(0.17 update)
(mipmap_count desc expansion regarding usefulness)
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Basics ==
{{Prototype parent}}
Prototype type: '''animation'''
 
Specifies a animation that can be used by https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation during runtime.
Specifies a animation that can be used by https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation during runtime.
== Mandatory properties ==


=== type ===
{{Prototype TOC|animation}}
'''Type''': [[Types/string]]


Must be "sprite".
== Mandatory properties ==
 
=== name ===
'''Type''': [[Types/string]]


Name of the sprite. Must be unique. Used in https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation.
{{Prototype property|type|[[Types/string|string]]}}
Must be "animation".


=== width ===
{{Prototype property|name|[[Types/string|string]]}}
'''Type''': [[Types/SpriteSizeType]]
Name of the animation. Must be unique. Used in https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation.
 
Width of one frame in pixels, from 1-8192.
 
=== height ===
'''Type''': [[Types/SpriteSizeType]]
 
Height of one frame in pixels, from 1-8192.
 
=== frame_count ===
'''Type''': [[Types/uint32]]
 
Can't be 0.


== Optional properties ==
== Optional properties ==


=== layers ===
{{Prototype property|layers|[[Types/table|table]] of [[Types/Animation|Animation]]|optional=true}}
'''Type''': [[Types/table]] of [[Types/Animation]]
 
If this property is present, all Animation definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Animation definition) in the array may also have the <code>layers</code> property.
If this property is present, all Animation definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Animation 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.
If this property is present, all other properties are ignored and the mandatory properties do not have to be defined.


=== hr_version ===
Layers may not be an empty table.
'''Type''': [[Types/Animation]]


{{Prototype property|hr_version|[[Types/Animation|Animation]]|optional=true}}
If this property exists and high resolution sprites are turned on, its contents are used to load the Animation.
If this property exists and high resolution sprites are turned on, its contents are used to load the Animation.


=== filename ===
{{Prototype property|filename|[[Types/FileName|FileName]]|""|optional=true}}
'''Type''': [[Types/FileName]]
Mandatory if <code>stripes</code> is not specified.
 
'''Default''': ""
 
Mandatory if <code>"stripes"</code> is not specified.
 
=== priority ===
'''Type''': [[Types/string]]
 
'''Default''': "medium"


Possible values:
{{Prototype property|priority|[[Types/SpritePriority|SpritePriority]]|"medium"|optional=true}}
* "extra-high-no-scale"
* "extra-high"
* "high"
* "medium"
* "low"
* "very-low"


=== flags ===
{{Prototype property|flags|[[Types/SpriteFlags|SpriteFlags]]|optional=true}}
'''Type''': [[Types/SpriteFlags]]
 
=== size ===
'''Type''': [[Types/SpriteSizeType]] or [[Types/table]] of [[Types/SpriteSizeType]]


{{Prototype property|size|[[Types/SpriteSizeType|SpriteSizeType]] or [[Types/table|table]] of [[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
The width and height of the one frame. 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.
The width and height of the one frame. 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 and height may only be in the range of 0-8192.


=== width ===
{{Prototype property|width|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
'''Type''': [[Types/SpriteSizeType]]
 
Mandatory if <code>size</code> is not given. Width of one frame in pixels, from 0-8192.
Mandatory if <code>size</code> is not given. Width of one frame in pixels, from 0-8192.


=== height ===
{{Prototype property|height|[[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
'''Type''': [[Types/SpriteSizeType]]
 
Mandatory if <code>size</code> is not given. Height of one frame in pixels, from 0-8192.
Mandatory if <code>size</code> is not given. Height of one frame in pixels, from 0-8192.


=== x ===
{{Prototype property|x|[[Types/SpriteSizeType|SpriteSizeType]]|0|optional=true}}
'''Type''': [[Types/SpriteSizeType]]
 
'''Default''': 0
 
Horizontal position of the animation in the source file in pixels.
Horizontal position of the animation in the source file in pixels.


=== y ===
{{Prototype property|y|[[Types/SpriteSizeType|SpriteSizeType]]|0|optional=true}}
'''Type''': [[Types/SpriteSizeType]]
 
'''Default''': 0
 
Vertical position of the animation in the source file in pixels.
Vertical position of the animation in the source file in pixels.


=== position ===
{{Prototype property|position|[[Types/table|table]] of [[Types/SpriteSizeType|SpriteSizeType]]|optional=true}}
'''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.
 
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}
 
=== scale ===
'''Type''': [[Types/double]]


'''Default''': 1
{{Prototype property|shift|[[Types/vector|vector]]|<nowiki>{0, 0}</nowiki>|optional=true}}


{{Prototype property|scale|[[Types/double|double]]|1|optional=true}}
Values different than 1 specify the scale of the animation on default zoom.
Values different than 1 specify the scale of the animation on default zoom.
Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).
Scale 2 means that the picture will be 2 times bigger on screen (and more pixelated).


=== draw_as_shadow ===
{{Prototype property|draw_as_shadow|[[Types/bool|bool]]|false|optional=true}}
'''Type''': [[Types/bool]]
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true. <code>draw_as_shadow</code> takes precedence over <code>draw_as_glow</code> and <code>draw_as_light</code>.


'''Default''': false
{{Prototype property|draw_as_glow |[[Types/bool|bool]]|false|optional=true}}
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true. <code>draw_as_glow</code> takes precedence over <code>draw_as_light</code>.


=== mipmap_count ===
Draws first as a normal sprite, and again as a light layer.<sup>[https://forums.factorio.com/91682]</sup>
'''Type''': [[Types/uint8]]


'''Default''': 0
{{Prototype property|draw_as_light |[[Types/bool|bool]]|false|optional=true}}
Only one of <code>draw_as_shadow</code>, <code>draw_as_glow</code> and <code>draw_as_light</code> can be true.


Only loaded if this is an icon (has flag "icon").
{{Prototype property|mipmap_count|[[Types/uint8|uint8]]|0|optional=true}}
Only loaded if this is an icon (has flag "group=icon" or "group=gui").<br>
Note: mipmap_count doesn't make sense in animation, as it is not possible to layout mipmaps in a way, that would load correctly both the animation and the mipmaps (besides animations with just one frame).[https://forums.factorio.com/viewtopic.php?p=549058#p549058]


=== apply_runtime_tint ===
{{Prototype property|apply_runtime_tint|[[Types/bool|bool]]|false|optional=true}}
'''Type''': [[Types/bool]]


'''Default''': false
{{Prototype property|tint|[[Types/Color|Color]]|<nowiki>{r=1, g=1, b=1, a=1} (white)</nowiki>|optional=true}}


=== tint ===
{{Prototype property|blend_mode|[[Types/BlendMode|BlendMode]]|"normal"|optional=true}}
'''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


{{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.
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 ===
{{Prototype property|premul_alpha|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/bool]]
 
'''Default''': true
 
Whether alpha should be premultiplied.
Whether alpha should be premultiplied.


=== generate_sdf ===
{{Prototype property|generate_sdf|[[Types/bool|bool]]|false|optional=true}}
'''Type''': [[Types/bool]]
Unused.
 
'''Default''': false
 
=== run_mode ===
'''Type''': [[Types/string]]
 
'''Default''': "forward"


{{Prototype property|run_mode|[[Types/string|string]]|"forward"|optional=true}}
Possible values are:
Possible values are:
*forward
*forward
Line 179: Line 93:
*forward-then-backward
*forward-then-backward


=== line_length ===
{{Prototype property|frame_count|[[Types/uint32|uint32]]|1|optional=true}}
'''Type''': [[Types/uint32]]
Can't be 0.
 
'''Default''': 0


{{Prototype property|line_length|[[Types/uint32|uint32]]|0|optional=true}}
Once the specified number of pictures is loaded, other pictures are loaded on other line.
Once the specified number of pictures is loaded, other pictures are loaded on other line.
This is to allow having longer animations in matrix, to avoid pictures with too big width.
This is to allow having longer animations in matrix, to avoid pictures with too big width.
The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.
The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.


=== animation_speed ===
{{Prototype property|animation_speed|[[Types/float|float]]|1|optional=true}}
'''Type''': [[Types/float]]
Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps).
The speed of playing can often vary depending on the usage (output of steam engine for example). Has to be greater than 0.


'''Default''': 1
{{Prototype property|max_advance|[[Types/float|float]]|MAX_FLOAT|optional=true}}


Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps).
{{Prototype property|repeat_count|[[Types/uint8|uint8]]|1|optional=true}}
The speed of playing can often vary depending on the usage (output of steam engine for example). Can't be 0.
Can't be 0.


=== max_advance ===
{{Prototype property|dice|[[Types/uint8|uint8]]|optional=true}}
'''Type''': [[Types/float]]


'''Default''': MAX_FLOAT
{{Prototype property|dice_x|[[Types/uint8|uint8]]|optional=true}}


=== repeat_count ===
{{Prototype property|dice_y|[[Types/uint8|uint8]]|optional=true}}
'''Type''': [[Types/uint8]]


'''Default''': 1
{{Prototype property|frame_sequence|[[Types/AnimationFrameSequence|AnimationFrameSequence]]|optional=true}}
 
Can't be 0.


=== stripes ===
{{Prototype property|stripes|[[Types/table|table]] of [[Types/Stripe|Stripe]]|optional=true}}

Revision as of 12:21, 29 July 2021

Prototype definitions » Prototype/Animation


Specifies a animation that can be used by https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation during runtime.


Prototype/Animation — animation
name::string
type::string
animation_speed::float (optional)
apply_runtime_tint::bool (optional)
blend_mode::BlendMode (optional)
dice::uint8 (optional)
dice_x::uint8 (optional)
dice_y::uint8 (optional)
draw_as_glow::bool (optional)
draw_as_light::bool (optional)
draw_as_shadow::bool (optional)
filename::FileName (optional)
flags::SpriteFlags (optional)
frame_count::uint32 (optional)
frame_sequence::AnimationFrameSequence (optional)
generate_sdf::bool (optional)
height::SpriteSizeType (optional)
hr_version::Animation (optional)
layers::table of Animation (optional)
line_length::uint32 (optional)
load_in_minimal_mode::bool (optional)
max_advance::float (optional)
mipmap_count::uint8 (optional)
position::table of SpriteSizeType (optional)
premul_alpha::bool (optional)
priority::SpritePriority (optional)
repeat_count::uint8 (optional)
run_mode::string (optional)
scale::double (optional)
shift::vector (optional)
size::SpriteSizeType or table of SpriteSizeType (optional)
stripes::table of Stripe (optional)
tint::Color (optional)
width::SpriteSizeType (optional)
x::SpriteSizeType (optional)
y::SpriteSizeType (optional)

Mandatory properties

type

Type: string
Must be "animation".

name

Type: string
Name of the animation. Must be unique. Used in https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_animation.

Optional properties

layers

Type: table of Animation
If this property is present, all Animation definitions have to be placed as entries in the array, and they will all be loaded from there. Each item (Animation 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.

hr_version

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

filename

Type: FileName
Default: ""
Mandatory if stripes is not specified.

priority

Type: SpritePriority
Default: "medium"

flags

Type: SpriteFlags

size

Type: SpriteSizeType or table of SpriteSizeType
The width and height of the one frame. 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: SpriteSizeType
Mandatory if size is not given. Width of one frame in pixels, from 0-8192.

height

Type: SpriteSizeType
Mandatory if size is not given. Height of one frame in pixels, from 0-8192.

x

Type: SpriteSizeType
Default: 0
Horizontal position of the animation in the source file in pixels.

y

Type: SpriteSizeType
Default: 0
Vertical position of the animation in the source file in pixels.

position

Type: table of 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: vector
Default: {0, 0}

scale

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

draw_as_shadow

Type: bool
Default: false
Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. draw_as_shadow takes precedence over draw_as_glow and draw_as_light.

draw_as_glow

Type: bool
Default: false
Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true. draw_as_glow takes precedence over draw_as_light.

Draws first as a normal sprite, and again as a light layer.[1]

draw_as_light

Type: bool
Default: false
Only one of draw_as_shadow, draw_as_glow and draw_as_light can be true.

mipmap_count

Type: uint8
Default: 0
Only loaded if this is an icon (has flag "group=icon" or "group=gui").
Note: mipmap_count doesn't make sense in animation, as it is not possible to layout mipmaps in a way, that would load correctly both the animation and the mipmaps (besides animations with just one frame).[2]

apply_runtime_tint

Type: bool
Default: false

tint

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

blend_mode

Type: BlendMode
Default: "normal"

load_in_minimal_mode

Type: 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: bool
Default: true
Whether alpha should be premultiplied.

generate_sdf

Type: bool
Default: false
Unused.

run_mode

Type: string
Default: "forward"
Possible values are:

  • forward
  • backward
  • forward-then-backward

frame_count

Type: uint32
Default: 1
Can't be 0.

line_length

Type: uint32
Default: 0
Once the specified number of pictures is loaded, other pictures are loaded on other line. This is to allow having longer animations in matrix, to avoid pictures with too big width. The game engine limits the width of any input picture to 2048px, so it is compatible with most graphics cards.

animation_speed

Type: float
Default: 1
Modifier of the animation playing speed, the default is 1, which means one animation frame per tick (60 fps). The speed of playing can often vary depending on the usage (output of steam engine for example). Has to be greater than 0.

max_advance

Type: float
Default: MAX_FLOAT

repeat_count

Type: uint8
Default: 1
Can't be 0.

dice

Type: uint8

dice_x

Type: uint8

dice_y

Type: uint8

frame_sequence

Type: AnimationFrameSequence

stripes

Type: table of Stripe