LUIS DAS ARTIMANHAS - Biblioteca Utilitária


Biblioteca utilitária para criação rápida de itens, receitas e outros protótipos Factorio.. local LDA = require('__LDA-LIB__/init') local PATH = LDA.setBasePath('Quantum-Teleporter')

Internal
3 days ago
2.0
144

a createAnimation AND createAnimationLayer FUNCTION

15 days ago
(updated 15 days ago)

createAnimation and createAnimationLayer function

createAnimation
--- Cria a estrutura completa de animação para um protótipo, a partir de uma ou mais layers.
-- (Esta função permaneceu inalterada, pois já tinha responsabilidade única)
-- @param layers_or_single_layer {table} Uma única layer de animação ou uma tabela com múltiplas layers.
-- @return {table} A estrutura final 'animation'.

usage
data:extend(
{
    {
        type = "assembling-machine",
        name = "my-new-machine",

        -- O uso da função pública de animação:
        animation = animation_utils.createAnimation(my_layer),

        -- ...
    }
})

createAnimationLayer
--- Função Pública: Cria uma única camada (layer) de animação.
-- Esta função é o orquestrador que utiliza as funções privadas para garantir o SRP.
-- @param filename {string} O caminho completo para o arquivo de imagem.
-- @param width {number} A largura da sprite na versão base.
-- @param height {number} A altura da sprite na versão base.
-- @param hr_scale {number|nil} O fator de escala para a versão HR (padrão: 0.5).
-- @param custom_props {table|nil} Propriedades customizadas.
-- @return {table} Um objeto de layer de animação completo, incluindo a hr_version.

usage
1. Cria a camada de animação (Layer)
local my_layer = animation_utils.createAnimationLayer(
    MOD_GRAPHICS_PATH .. "assembly-unit-main.png", -- filename
    128,                                           -- width (Base)
    128,                                           -- height (Base)
    0.5,                                           -- hr_scale (HR será 256x256)
    {                                              -- custom_props
        shift = {0, 0.125},
        frame_count = 16,                          -- 16 frames no sprite-sheet
        line_length = 8,                           -- 8 frames por linha
        animation_speed = 0.5
    }
)

função completa desenvolvida

New response