Turret raising_animation can't use several spritesheets

Place to get help with not working mods / modding interface.
Bloodymight
Inserter
Inserter
Posts: 20
Joined: Sun Nov 04, 2018 4:21 pm
Contact:

Turret raising_animation can't use several spritesheets

Post by Bloodymight »

Hi, I was trying to do a rather detailed raising animation for a turret with 2 spritesheets for each side, the sprite sheets have each 8x8 sprites

...I couldn't make it work, it always gave me a ROOT error(afaik), which confused me, because it worked for the attack animation...

anyways I reduced it to one spritesheet for each side, but the game only makes use of the north animation, the others are ignored (probably because I set direction_count = 1)

currently the file looks like this, (I used Bob stuff as a base, since I was playing with/modifying his files for private use anyway, had fun adding sound effects and now spritesheets etc. and it kinda escalated)

Code: Select all

function antimatter_turret_preparing_north(inputs)
local size = inputs.size or 1
return
{
  layers =
  {
    {
      filenames = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-north-comb.png",
      priority = "medium",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count and inputs.frame_count or 64,
      line_length = inputs.line_length and inputs.line_length or 8,
      lines_per_file = 8,
      run_mode = inputs.run_mode and inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      --shift = util.by_pixel(0, -32 * size),
      scale = 2 * size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-north-comb.png",
        priority = "medium",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count and inputs.frame_count or 64,
        line_length = inputs.line_length and inputs.line_length or 8,
        run_mode = inputs.run_mode and inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        --shift = util.by_pixel(0, -32.5 * size),
        scale = size
      }
    },
    -- {
      -- filename = "__base__/graphics/entity/laser-turret/laser-turret-raising-mask.png",
      -- flags = { "mask" },
      -- width = 44,
      -- height = 40,
      -- frame_count = inputs.frame_count or 15,
      -- line_length = inputs.line_length or 0,
      -- run_mode = inputs.run_mode or "forward",
      -- axially_symmetrical = false,
      -- tint = inputs.tint or white,
      -- direction_count = 4,
      -- shift = util.by_pixel(0, -43 * size),
      -- scale = size,
      -- hr_version = {
        -- filename = "__base__/graphics/entity/laser-turret/hr-laser-turret-raising-mask.png",
        -- flags = { "mask" },
        -- width = 86,
        -- height = 80,
        -- frame_count = inputs.frame_count or 15,
        -- line_length = inputs.line_length or 0,
        -- run_mode = inputs.run_mode or "forward",
        -- axially_symmetrical = false,
        -- tint = inputs.tint or white,
        -- direction_count = 4,
        -- shift = util.by_pixel(0, -43 * size),
        -- scale = 0.5 * size
      -- }
    -- },
    {
      filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-shadow.png",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count or 64,
      line_length = inputs.line_length or 8,
      run_mode = inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      draw_as_shadow = true,
      --shift = util.by_pixel(47 * size, 3 * size),
      scale = size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-shadow.png",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count or 64,
        line_length = inputs.line_length or 8,
        run_mode = inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        draw_as_shadow = true,
        --shift = util.by_pixel(47 * size, 2.5 * size),
        scale = 0.5 * size
      }
    }
  }
}
end

function antimatter_turret_preparing_east(inputs)
local size = inputs.size or 1
return
{
  layers =
  {
    {
      filenames = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-east-comb.png",
      priority = "medium",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count and inputs.frame_count or 64,
      line_length = inputs.line_length and inputs.line_length or 8,
      lines_per_file = 8,
      run_mode = inputs.run_mode and inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      --shift = util.by_pixel(0, -32 * size),
      scale = 2 * size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-east-comb.png",
        priority = "medium",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count and inputs.frame_count or 64,
        line_length = inputs.line_length and inputs.line_length or 8,
        run_mode = inputs.run_mode and inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        --shift = util.by_pixel(0, -32.5 * size),
        scale = size
      }
    },
    -- {
      -- filename = "__base__/graphics/entity/laser-turret/laser-turret-raising-mask.png",
      -- flags = { "mask" },
      -- width = 44,
      -- height = 40,
      -- frame_count = inputs.frame_count or 15,
      -- line_length = inputs.line_length or 0,
      -- run_mode = inputs.run_mode or "forward",
      -- axially_symmetrical = false,
      -- tint = inputs.tint or white,
      -- direction_count = 4,
      -- shift = util.by_pixel(0, -43 * size),
      -- scale = size,
      -- hr_version = {
        -- filename = "__base__/graphics/entity/laser-turret/hr-laser-turret-raising-mask.png",
        -- flags = { "mask" },
        -- width = 86,
        -- height = 80,
        -- frame_count = inputs.frame_count or 15,
        -- line_length = inputs.line_length or 0,
        -- run_mode = inputs.run_mode or "forward",
        -- axially_symmetrical = false,
        -- tint = inputs.tint or white,
        -- direction_count = 4,
        -- shift = util.by_pixel(0, -43 * size),
        -- scale = 0.5 * size
      -- }
    -- },
    {
      filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-shadow.png",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count or 64,
      line_length = inputs.line_length or 8,
      run_mode = inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      draw_as_shadow = true,
      --shift = util.by_pixel(47 * size, 3 * size),
      scale = size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-shadow.png",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count or 64,
        line_length = inputs.line_length or 8,
        run_mode = inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        draw_as_shadow = true,
        --shift = util.by_pixel(47 * size, 2.5 * size),
        scale = 0.5 * size
      }
    }
  }
}
end

function antimatter_turret_preparing_south(inputs)
local size = inputs.size or 1
return
{
  layers =
  {
    {
      filenames = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-south-comb.png",
      priority = "medium",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count and inputs.frame_count or 64,
      line_length = inputs.line_length and inputs.line_length or 8,
      lines_per_file = 8,
      run_mode = inputs.run_mode and inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      --shift = util.by_pixel(0, -32 * size),
      scale = 2 * size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-south-comb.png",
        priority = "medium",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count and inputs.frame_count or 64,
        line_length = inputs.line_length and inputs.line_length or 8,
        run_mode = inputs.run_mode and inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        --shift = util.by_pixel(0, -32.5 * size),
        scale = size
      }
    },
    -- {
      -- filename = "__base__/graphics/entity/laser-turret/laser-turret-raising-mask.png",
      -- flags = { "mask" },
      -- width = 44,
      -- height = 40,
      -- frame_count = inputs.frame_count or 15,
      -- line_length = inputs.line_length or 0,
      -- run_mode = inputs.run_mode or "forward",
      -- axially_symmetrical = false,
      -- tint = inputs.tint or white,
      -- direction_count = 4,
      -- shift = util.by_pixel(0, -43 * size),
      -- scale = size,
      -- hr_version = {
        -- filename = "__base__/graphics/entity/laser-turret/hr-laser-turret-raising-mask.png",
        -- flags = { "mask" },
        -- width = 86,
        -- height = 80,
        -- frame_count = inputs.frame_count or 15,
        -- line_length = inputs.line_length or 0,
        -- run_mode = inputs.run_mode or "forward",
        -- axially_symmetrical = false,
        -- tint = inputs.tint or white,
        -- direction_count = 4,
        -- shift = util.by_pixel(0, -43 * size),
        -- scale = 0.5 * size
      -- }
    -- },
    {
      filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-shadow.png",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count or 64,
      line_length = inputs.line_length or 8,
      run_mode = inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      draw_as_shadow = true,
      --shift = util.by_pixel(47 * size, 3 * size),
      scale = size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-shadow.png",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count or 64,
        line_length = inputs.line_length or 8,
        run_mode = inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        draw_as_shadow = true,
        --shift = util.by_pixel(47 * size, 2.5 * size),
        scale = 0.5 * size
      }
    }
  }
}
end

function antimatter_turret_preparing_west(inputs)
local size = inputs.size or 1
return
{
  layers =
  {
    {
      filenames = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-west-comb.png",
      priority = "medium",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count and inputs.frame_count or 64,
      line_length = inputs.line_length and inputs.line_length or 8,
      lines_per_file = 8,
      run_mode = inputs.run_mode and inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      --shift = util.by_pixel(0, -32 * size),
      scale = 2 * size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-west-comb.png",
        priority = "medium",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count and inputs.frame_count or 64,
        line_length = inputs.line_length and inputs.line_length or 8,
        run_mode = inputs.run_mode and inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        --shift = util.by_pixel(0, -32.5 * size),
        scale = size
      }
    },
    -- {
      -- filename = "__base__/graphics/entity/laser-turret/laser-turret-raising-mask.png",
      -- flags = { "mask" },
      -- width = 44,
      -- height = 40,
      -- frame_count = inputs.frame_count or 15,
      -- line_length = inputs.line_length or 0,
      -- run_mode = inputs.run_mode or "forward",
      -- axially_symmetrical = false,
      -- tint = inputs.tint or white,
      -- direction_count = 4,
      -- shift = util.by_pixel(0, -43 * size),
      -- scale = size,
      -- hr_version = {
        -- filename = "__base__/graphics/entity/laser-turret/hr-laser-turret-raising-mask.png",
        -- flags = { "mask" },
        -- width = 86,
        -- height = 80,
        -- frame_count = inputs.frame_count or 15,
        -- line_length = inputs.line_length or 0,
        -- run_mode = inputs.run_mode or "forward",
        -- axially_symmetrical = false,
        -- tint = inputs.tint or white,
        -- direction_count = 4,
        -- shift = util.by_pixel(0, -43 * size),
        -- scale = 0.5 * size
      -- }
    -- },
    {
      filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-shadow.png",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count or 64,
      line_length = inputs.line_length or 8,
      run_mode = inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 1,
      draw_as_shadow = true,
      --shift = util.by_pixel(47 * size, 3 * size),
      scale = size,
      hr_version =
      {
        filename = "__bobwarfare__/graphics/entities/antimatterturret/hr-antimatter-turret-raising-shadow.png",
        width = 1024,
        height = 1024,
        frame_count = inputs.frame_count or 64,
        line_length = inputs.line_length or 8,
        run_mode = inputs.run_mode or "forward",
        axially_symmetrical = false,
        direction_count = 1,
        draw_as_shadow = true,
        --shift = util.by_pixel(47 * size, 2.5 * size),
        scale = 0.5 * size
      }
    }
  }
}
end

Code: Select all

function antimatter_turret(inputs)
local size = inputs.size or 1
local turret =
  {
    type = "electric-turret",
    name = inputs.name,
    icon = "__base__/graphics/icons/laser-turret.png",
    icon_size = 64,
    icon_mipmaps = 4,
    flags = { "placeable-player", "placeable-enemy", "player-creation"},
    minable = { mining_time = 0.5, result = inputs.name },
    max_health = inputs.health,
    corpse = "laser-turret-remnants",
    collision_box = {{ -4.8 * size, -6.8 * size}, {4.8 * size, 2.8 * size}},
    selection_box = {{ -5 * size, -7 * size}, {5 * size, 3 * size}},
    dying_explosion = inputs.dying_explosion or "laser-turret-explosion",
    rotation_speed = inputs.rotation_speed or 0.01,
    preparing_speed = inputs.preparing_speed or 0.05,
    folding_speed = inputs.folding_speed or 0.05,
	working_sound = inputs.working_sound,
	activate_sound = inputs.activate_sound,
	prepared_sound = inputs.prepared_sound,
	folding_sound = inputs.folding_sound,
	preparing_sound = inputs.preparing_sound,
    fast_replaceable_group = "turret",
    turret_base_has_direction = inputs.turret_base_has_direction,
    energy_source = inputs.energy_source or
    {
      type = "electric",
      buffer_capacity = inputs.buffer_capacity or "801kJ",
      input_flow_limit = inputs.input_flow_limit or "4800kW",
      drain = inputs.drain or "24kW",
      usage_priority = "primary-input"
    },
    folded_animation = bob_laser_turret_extension{frame_count=1, line_length = 1, tint = inputs.tint, size = size},
	preparing_animation = {
	north = antimatter_turret_preparing_north{tint = inputs.tint, size = size}, 
	east = antimatter_turret_preparing_east{tint = inputs.tint, size = size},
	south = antimatter_turret_preparing_south{tint = inputs.tint, size = size},
	west = antimatter_turret_preparing_west{tint = inputs.tint, size = size},
	},
	
	
	-- preparing_animation.east = antimatter_turret_preparing_east,
	-- preparing_animation.south = antimatter_turret_preparing_south,
	-- preparing_animation.west = antimatter_turret_preparing_west,
    folding_animation = bob_laser_turret_extension{run_mode = "backward", tint = inputs.tint, size = size},
    prepared_animation = antimatter_turret_attack{size = size},
    base_picture = inputs.base,
    vehicle_impact_sound =  { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
    call_for_help_radius = 40
  }
    turret.attack_parameters =
    {
      type = "beam",
      cooldown = inputs.cooldown or 40,
      range = inputs.range or 25,
      source_direction_count = 64,
      source_offset = {0, 0},--(-20.423489 )* size },
      damage_modifier = inputs.damage_modifier or 2,
      turn_range = inputs.turn_range,
	  health_penalty = inputs.health_penalty,
	  cooldown = inputs.cooldown or nil,
	  min_range = inputs.min_range,
	  warmup = inputs.warmup or nil, --hinzugefügt
      ammo_type =
      {
        category = "laser",
        energy_consumption = inputs.energy_consumption or "800kJ",
        action =
        {
          type = "direct",
          action_delivery =
          {
            type = "beam",
            beam = inputs.beam or "laser-beam",
            max_length = inputs.range or 25,
            duration = inputs.cooldown or 40,
            source_offset = {0, -1.31439 * size }
          }
        }
      },
    }

  return turret
end

Before ending up with the stuff as it is seen above, I tried to make it work with sprites ={} or filenames ={}

Code: Select all

	    
	width = 512,
      height = 512,
      frame_count = 128,
      axially_symmetrical = false, 
      direction_count = 4,
	--sprites
	     {
          -- filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-3.png",
          -- width_in_frames = inputs.frame_count or 8,
          -- height_in_frames = 8
        -- },
        -- {
          -- filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-4.png",
          -- width_in_frames = inputs.frame_count or 8,
          -- height_in_frames = 8
        -- },

Code: Select all

        -- filenames =
        -- {
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-1.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-2.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-3.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-4.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-5.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-6.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-7.png",
		-- "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-comb-8.png",
        -- },
          -- lines_per_file = 8,
          -- line_length = 8,
          -- width = 512,
          -- height = 512,
          -- frame_count = 128,
          -- shift = util.mul_shift(util.by_pixel(-1, -5), scale),
          -- direction_count = 4,
          -- scale = 2 * scale
        

I also noticed had problems for the attacking animation, I used 2 sprite sheets(8x8x2) for the main animation but for the shadow only one sprite, because it was sufficient.
So when trying to add the shadow, the game didn't load with it using layers, so I just removed the shadows for now.
I'm guessing, since I used 2 sprite sheets with 8x8 sprites each and the shadow having only one sprite, it wants for each sprite a shadow when using layers.. so I think I have to use 128sprites for the shadow to make it work, which is not necessary.

PS. my scripting isn't really that great, I only used the things that were given already
PS² I know the sprite resolution is excessive, but anything below 256 doesn't look that great since it is a giant structure( and I was having a case of "why not")
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

Re: Turret raising_animation can't use several spritesheets

Post by Deadlock989 »

I am finding it difficult to understand most of this.

Are you really trying to make a raising animation with 128 frames per direction? If so that is ... a lot, especially with such large sprites. As a point of comparison, the base game uses 5 raising/folding frames for gun turrets and 15 for laser turrets.

For turrets and other multi-direction entities with per-direction animations you can make life a lot easier for yourself by organising spritesheets so that each direction is a row and each frame of the animation is a column. If you have more than 8 directions (e.g. vehicles) you can use the "stripes" property to more easily split them across files. ("sprites" is not a valid property - you are probably thinking of "stripes").

If you have a situation where your shadow is identical across all of a direction's frames, you can use repeat_count to match the number of the frames so that 1 shadow sprite is used for each animated frame.
Bloodymight
Inserter
Inserter
Posts: 20
Joined: Sun Nov 04, 2018 4:21 pm
Contact:

Re: Turret raising_animation can't use several spritesheets

Post by Bloodymight »

Deadlock989 wrote: Fri Sep 16, 2022 8:54 am Are you really trying to make a raising animation with 128 frames per direction? If so that is ... a lot, especially with such large sprites. As a point of comparison, the base game uses 5 raising/folding frames for gun turrets and 15 for laser turrets.
yes, but I couldn't make it accept 2 spritesheets. It just didn't load and gave me a ROOT error..
So I reduced it to one spritesheet(64 frames) per direction but that just kind of worked, which means,
its just using the north animation, even when I increase the "direction_count" to 4, it'll just calculate the sprite towards one direction and try to use it, which doesn't work, because first, the resolution would be too big, and second, one sprite sheet is for just one direction anyway


and I guess I forgot to ask a question

Is there a way to make the preparing animation work with multiple sprite sheets for each direction?
and
even if not, how can I make it use one sprite sheet for each direction?(north, east, south, west)

in the wiki it sais for both

prepared_animation
Type: RotatedAnimation4Way

preparing_animation
Type: RotatedAnimation4Way


It is possible to load and use multiple sprite sheets with for example the artillery turret and or other turrets so it is a bit confusing that the same thing that worked for one doesn't work on the other animation type.

It made sense for me to use it the same way in the preparing_animation as I did with prepared_animation since the latter worked.

I do think though that I'm missing something

Deadlock989 wrote: Fri Sep 16, 2022 8:54 am For turrets and other multi-direction entities you can make life a lot easier for yourself by organising spritesheets so that each direction is a row and each frame of the animation is a column. If you have more than 8 directions (e.g. vehicles) you can use the "stripes" property to more easily split them across files. ("sprites" is not a valid property - you are probably thinking of "stripes").
What wait, let me see, i did write sprites and not stripes
Deadlock989 wrote: Fri Sep 16, 2022 8:54 am If you have a situation where your shadow is identical across all of a direction's frames, you can use repeat_count to match the number of the frames so that 1 shadow sprite is used for each animated frame.
perfect, thank you, let me try this as well
Bloodymight
Inserter
Inserter
Posts: 20
Joined: Sun Nov 04, 2018 4:21 pm
Contact:

Re: Turret raising_animation can't use several spritesheets

Post by Bloodymight »

Deadlock989 wrote: Fri Sep 16, 2022 8:54 am ("sprites" is not a valid property - you are probably thinking of "stripes").
thanks lol!

So I corrected my code, game is starting, it is again kind of working, just doing something weird with the sprite when the turret is raising.
BUT at least it is loading now

Code: Select all

  layers =
  {
    {
      -- filenames = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-north-comb.png",
      stripes =
      {
        {
          filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-north-comb.png",
          width_in_frames = inputs.frame_count or 8,
          height_in_frames = 8
        },
        {
          filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-east-comb.png",
          width_in_frames = inputs.frame_count or 8,
          height_in_frames = 8
        },
        {
          filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-south-comb.png",
          width_in_frames = inputs.frame_count or 8,
          height_in_frames = 8
        },
        {
          filename = "__bobwarfare__/graphics/entities/antimatterturret/antimatter-turret-raising-west-comb.png",
          width_in_frames = inputs.frame_count or 8,
          height_in_frames = 8
        },
      },
      priority = "medium",
      width = 512,
      height = 512,
      frame_count = inputs.frame_count and inputs.frame_count or 64,
      line_length = inputs.line_length and inputs.line_length or 8,
      lines_per_file = 8,
      run_mode = inputs.run_mode and inputs.run_mode or "forward",
      axially_symmetrical = false,
      direction_count = 4,
      scale = 2 * size,

    }
    }
the animation makes use of the sprite sheets now, the direction seems to be working aswell but the animation is jumpy and not correct
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

Re: Turret raising_animation can't use several spritesheets

Post by Deadlock989 »

You have chosen one of the most difficult places in the game to start modding sprites/animations. Clearly something is wrong with your numbers but it's hard to tell what.

The difference with artillery cannon sprites (as far as I understand it) is that they are a RotatedSprite and don't support animations (multiple frames per direction). Turret sprites are a RotatedAnimation4Way as you have discovered. For those you can either specify all the directions in one set of layers (you have to do this if you force them to have 8 directions) or per-direction as a RotatedAnimation for each of north, south, east, west.

For RotatedAnimation, multi-file spritesheets are possible. Either you use filenames to list the sheets in order and then also use line_length and lines_per_file so that it knows how many lines are in each file - all of those numbers have to add up properly or you will get errors on load (or at best some janky animations).

Or you might be able to use stripes, which the base game mostly uses for entities with a lot more than 4 directions such as vehicles - I have never actually tried that with turrets myself, the most I have ever pushed the boat out for was an 8-direction turret with 16 raising/folding animations per direction.

There is also the slice method which the base game only uses for biter and spitter animations but if I'm honest I understand that one very poorly.

My advice is to try something simpler first, understand it fully, and build up to handling one of the most complex animations in the game later. ;)
Last edited by Deadlock989 on Fri Sep 16, 2022 12:34 pm, edited 3 times in total.
Bloodymight
Inserter
Inserter
Posts: 20
Joined: Sun Nov 04, 2018 4:21 pm
Contact:

Re: Turret raising_animation can't use several spritesheets

Post by Bloodymight »

Deadlock989 wrote: Fri Sep 16, 2022 12:26 pm Or you might be able to use stripes, which the base game mostly uses for entities with a lot more than 4 directions such as vehicles - I have never actually tried that with turrets myself, the most I have ever pushed the boat out for was an 8-direction turret with 16 raising/folding animations per direction.
I think this is exactly what I need, I did use stripes now(not sprites lol) and the game loads, problem is, as described above your post, that the animation is off, the direction it ends up is correct though rofl

I mean it does look funny, kind of like a sound driver


Edit:
expectation:
https://youtu.be/7btNvcA7Zeg

reality:
https://youtu.be/KSzJ9GcE-Fg


Video might be loading still, since I just uploaded them
Bloodymight
Inserter
Inserter
Posts: 20
Joined: Sun Nov 04, 2018 4:21 pm
Contact:

Re: Turret raising_animation can't use several spritesheets

Post by Bloodymight »

so I got it to work now with 4 png files

I just had to change the order of the frames in each sheet as a final step,
since it loads all png files at once and puts them next to each other, then goes line by line, till it reaches the 64 frames I set for each direction.
Post Reply

Return to “Modding help”