Types/AnimationFrameSequence: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Updated styling of prototype doc migration note)
(Removed old prototype docs)
 
Line 2: Line 2:


</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>
</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>
An [[Types/table|array]] of [[Types/uint16]]. Used by [[Types/Animation]] and similar.
This is a list of 1-based frame indices into the spritesheet. The actual length of the animation will then be the length of the frame_sequence (times <code>repeat_count</code>, times two if <code>run_mode</code> is "forward-then-backward"). There is a limit for (actual) animation length of 255 frames.
Indices can be used in any order, repeated or not used at all. Unused frames are not loaded into VRAM at all, frames referenced multiple times are loaded just once.[https://forums.factorio.com/53202]
== Examples ==
Trivial example - frame_sequence defines same sequence in which the animation would load by default, so it is useless in this case:
<syntaxhighlight lang="lua">
  frame_count = 4,
  frame_sequence = { 1, 2, 3, 4 }
</syntaxhighlight>
Usage example - first five times repeat frame 2, then alternate between 4 and 3 two times. Frame 1 is not used:
<syntaxhighlight lang="lua">
  frame_count = 4,
  frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 }
</syntaxhighlight>
Complex example - animation contains different layers with different frame counts
<syntaxhighlight lang="lua">
  local custom_frame_sequence = { 2, 2, 2, 2, 2, 4, 3, 4, 3 }
  layers = {
    {
      -- Animation with custom frame sequence
      frame_count = 4,
      frame_sequence = custom_frame_sequence,
    },
    {
      -- Single sprite that's repeated
      repeat_count = #custom_frame_sequence,
    },
    {
      -- Other animation with different frame count
      -- Assuming: #custom_frame_sequence < frame_count
      frame_count = #custom_frame_sequence,
    },
  }
</syntaxhighlight>

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/AnimationFrameSequence.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.