Remnants for a non-square Entity

Place to get help with not working mods / modding interface.
Post Reply
User avatar
tiriscef
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Thu Mar 28, 2019 8:45 pm
Contact:

Remnants for a non-square Entity

Post by tiriscef »

Hey,

I have a fairly big non-square entity and I created a remnant for each rotation of it. But then a problem arises: The game picks one rotation at random, which looks really weird:
Image
I was really shocked.

My code for the corpse is:

Code: Select all

Tirislib_Entity.create {
    type = "corpse",
    name = "farm-remnants",
    icon = "__sosciencity__/graphics/icon/farm.png",
    icon_size = 32,
    flags = {"placeable-neutral", "not-on-map"},
    selectable_in_game = false,
    time_before_removed = 60 * 60 * 15, -- 15 minutes
    final_render_layer = "remnants",
    subgroup = "remnants",
    order = "dead-farm:(",
    remove_on_tile_placement = false,
    tile_width = 15,
    tile_height = 7,
    animation = {
        {
            filename = "__sosciencity__/graphics/entity/farm/farm-north-remnants.png",
            frame_count = 1,
            width = 544,
            height = 288,
            direction_count = 1,
            hr_version = {
                filename = "__sosciencity__/graphics/entity/farm/farm-north-remnants-hr.png",
                frame_count = 1,
                width = 1088,
                height = 576,
                direction_count = 1,
                scale = 0.5
            }
        },
        {
            filename = "__sosciencity__/graphics/entity/farm/farm-east-remnants.png",
            frame_count = 1,
            width = 288,
            height = 544,
            direction_count = 1,
            hr_version = {
                filename = "__sosciencity__/graphics/entity/farm/farm-east-remnants-hr.png",
                frame_count = 1,
                width = 576,
                height = 1088,
                direction_count = 1,
                scale = 0.5
            }
        },
        {
            filename = "__sosciencity__/graphics/entity/farm/farm-south-remnants.png",
            frame_count = 1,
            width = 544,
            height = 288,
            direction_count = 1,
            hr_version = {
                filename = "__sosciencity__/graphics/entity/farm/farm-south-remnants-hr.png",
                frame_count = 1,
                width = 1088,
                height = 576,
                direction_count = 1,
                scale = 0.5
            }
        },
        {
            filename = "__sosciencity__/graphics/entity/farm/farm-west-remnants.png",
            frame_count = 1,
            width = 288,
            height = 544,
            direction_count = 1,
            hr_version = {
                filename = "__sosciencity__/graphics/entity/farm/farm-west-remnants-hr.png",
                frame_count = 1,
                width = 576,
                height = 1088,
                direction_count = 1,
                scale = 0.5
            }
        }
    }
}:set_size(15, 7)
I looked at the code of the steam engine and the boiler of the base game, but I didn't understand how the base game avoids this problem.
I also tried to set variation_count and axially_symmetrical (whatever that does), but the problem still arised.

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Remnants for a non-square Entity

Post by Honktown »

I'm looking at corpses, and technically pipes may be the only entity which has directions to the corpse.

From what I can see, only the width and y values change from corpse to corpse graphic. Possibly the game looks for the entity which has the same height, width, and y value, and automatically matches rotation. If your north/south east/west graphics are not mirrored, I wouldn't guess if it's even possible.

I would've guessed it might be hard-coded to do NSEW in order of definitions, but your mod randomly choosing orientations negates that theory.
I have mods! I guess!
Link

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Remnants for a non-square Entity

Post by posila »

You defined your corpse animation as 1 direction with 4 variations, so it's picking randomly one of the variations.

Note: pipes, walls, heat pipes, and underground belts have special override for orientation based on their connections when they were destroyed (or if it was input or output in case of underground belt), corpses for everything else should inherit direction from the entity that created it.

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Remnants for a non-square Entity

Post by Bilka »

posila wrote:
Wed Dec 04, 2019 11:27 am
You defined your corpse animation as 1 direction with 4 variations, so it's picking randomly one of the variations.

Note: pipes, walls, heat pipes, and underground belts have special override for orientation based on their connections when they were destroyed (or if it was input or output in case of underground belt), corpses for everything else should inherit direction from the entity that created it.
To expand on this, the wiki was wrong, it documented RotatedAnimationVariations as a list of AnimationVariations, but it is a list of RotatedAnimation. So, you'd have one RotatedAnimation in the outer list and then all 4 directions in that one RotatedAnimation. Sorry about the incorrect documentation :/
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
tiriscef
Long Handed Inserter
Long Handed Inserter
Posts: 98
Joined: Thu Mar 28, 2019 8:45 pm
Contact:

Re: Remnants for a non-square Entity

Post by tiriscef »

Hey,
thanks for the speedy answers. :)

In case it is the future and you are looking for an answer to a similar problem, this is the working code:

Code: Select all

Tirislib_Entity.create {
    type = "corpse",
    name = "farm-remnants",
    icon = "__sosciencity__/graphics/icon/farm.png",
    icon_size = 64,
    flags = {"placeable-neutral", "not-on-map"},
    selectable_in_game = false,
    time_before_removed = 60 * 60 * 15, -- 15 minutes
    final_render_layer = "remnants",
    subgroup = "remnants",
    order = "dead-farm:(",
    remove_on_tile_placement = false,
    tile_width = 15,
    tile_height = 7,
    animation = {
        direction_count = 4,
        width = 544,
        height = 544,
        stripes = {
            {
                filename = "__sosciencity__/graphics/entity/farm/farm-north-remnants.png",
                width_in_frames = 1,
                height_in_frames = 1
            },
            {
                filename = "__sosciencity__/graphics/entity/farm/farm-east-remnants.png",
                width_in_frames = 1,
                height_in_frames = 1
            },
            {
                filename = "__sosciencity__/graphics/entity/farm/farm-south-remnants.png",
                width_in_frames = 1,
                height_in_frames = 1
            },
            {
                filename = "__sosciencity__/graphics/entity/farm/farm-west-remnants.png",
                width_in_frames = 1,
                height_in_frames = 1
            }
        },
        hr_version = {
            direction_count = 4,
            width = 1088,
            height = 1088,
            scale = 0.5,
            stripes = {
                {
                    filename = "__sosciencity__/graphics/entity/farm/farm-north-remnants-hr.png",
                    width_in_frames = 1,
                    height_in_frames = 1
                },
                {
                    filename = "__sosciencity__/graphics/entity/farm/farm-east-remnants-hr.png",
                    width_in_frames = 1,
                    height_in_frames = 1
                },
                {
                    filename = "__sosciencity__/graphics/entity/farm/farm-south-remnants-hr.png",
                    width_in_frames = 1,
                    height_in_frames = 1
                },
                {
                    filename = "__sosciencity__/graphics/entity/farm/farm-west-remnants-hr.png",
                    width_in_frames = 1,
                    height_in_frames = 1
                }
            }
        }
    }
}:set_size(15, 7)
Notice that I made the sprites square, because the stripes property expects them to all have the same size.
But the game crops away all the unnecessary transparent spaces, so this solution doesn't waste vram.

Post Reply

Return to “Modding help”