Cut off Graphics

Place to get help with not working mods / modding interface.
Post Reply
Petrenko
Inserter
Inserter
Posts: 32
Joined: Mon Mar 20, 2017 1:10 pm
Contact:

Cut off Graphics

Post by Petrenko »

Heyho,

i made a rifleman.

The problem is, some animations got cut off and i think it got something to do with the shifting in the animations.

Is there a formula one could use?

I based him off the small biter.

Here you got the animation:

Code: Select all

function rus_rifleman_1_runanimation(scale)
  return
  {
    layers=
    {
      {
        width = 190,
        height = 125,
        frame_count = 8,
        direction_count = 16,
        shift = { 0.0, 0.0},
        scale = scale,
        stripes =
        {
         {
          filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",
          width_in_frames = 8,
          height_in_frames = 16,
         },
         {
          filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",
          width_in_frames = 8,
          height_in_frames = 16,
         }
        }
      }
	}
  }
end
Here you got himself:

Code: Select all

data:extend(
{
  {
    type = "unit",
    name = "rus_rifleman_1",
    icon = "__base__/graphics/icons/small-biter.png",
    flags = {"placeable-player", "placeable-enemy", "placeable-off-grid", "breaths-air"},
    max_health = 15,
    order = "b-b-a",
    subgroup="creatures",
	minable = {hardness = 0.1, mining_time = 0.1, result = "rus_rifleman_1_item"},
    healing_per_tick = 0.01,
    collision_box = {{-0.5, -0.5}, {0.5, 0.5}},
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    attack_parameters =
    {
      type = "projectile",
      range = 12.5,
      cooldown = 35,
      ammo_category = "melee",
      ammo_type = make_unit_melee_ammo_type(6),
      sound = make_biter_roars(0.5),
      animation = rus_rifleman_1_attackanimation(riflemanscale)
    },
    vision_distance = 30,
    movement_speed = 0.1,
    distance_per_frame = 0.4,
    pollution_to_join_attack = 200,
    distraction_cooldown = 300,
    dying_explosion = "blood-explosion-small",
    dying_sound =  make_biter_dying_sounds(1.0),
    working_sound =  make_biter_calls(0.7),
    run_animation = rus_rifleman_1_runanimation(riflemanscale)
  }
}
)
Thanks in advance for any help =)

Petrenko
Inserter
Inserter
Posts: 32
Joined: Mon Mar 20, 2017 1:10 pm
Contact:

Re: Cut off Graphics

Post by Petrenko »

I'm adding my spritesheet for reference.
Attachments
rus_rifleman_1_run.png
rus_rifleman_1_run.png (987.36 KiB) Viewed 2143 times

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Cut off Graphics

Post by 321freddy »

What exactly is getting cut off?
Shift is used to align the sprite correctly in case it is off center but since you only have one layer in your animation this shouldn't cause any real issue.

Also why are you declaring the same run animation file twice inside stripes in the runanimaton function.
The stripes parameter is used when you want to combine multiple source images because one would be too large. So you should replace the whole stripes section with the following line:

Code: Select all

filename = "__robotarmy__/graphics/entity/rus_rifleman_1/rus_rifleman_1_run.png",

Petrenko
Inserter
Inserter
Posts: 32
Joined: Mon Mar 20, 2017 1:10 pm
Contact:

Re: Cut off Graphics

Post by Petrenko »

Heyho,

thank you for having a look.

I got rid of the stripes and also killed the shift.

Still it cuts off on the left. It's hard to describe.

Have a look:
Attachments
error03.png
error03.png (81.46 KiB) Viewed 2114 times
error02.png
error02.png (51.75 KiB) Viewed 2114 times
error01.png
error01.png (64.41 KiB) Viewed 2114 times

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Cut off Graphics

Post by prg »

Can't repro.
rifleman.jpg
rifleman.jpg (17.04 KiB) Viewed 2105 times
Maybe try deleting crop-cache.dat, might help if you were using a different image with the same name previously and now things got confused somehow.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Cut off Graphics

Post by 321freddy »

Ok I just tested it with your code and it works perfectly on my side:
Image

Sorry I have no idea what the problem is, maybe it's your computer or some internal factorio bug. Maybe your game ran out of video memory?
Here is the data.lua code I used to test it, I only changed some the image paths and experimented a little with shift, maybe you can spot the difference:

Code: Select all

function rus_rifleman_1_runanimation(scale)
  return
  {
    layers=
    {
      {
        width = 190,
        height = 125,
        frame_count = 8,
        direction_count = 16,
        shift = { scale * 1.5, scale * -0.5},
        scale = scale,
        filename = "__test-mod__/rus_rifleman_1_run.png",
      }
   }
  }
end

riflemanscale = 1

data:extend{
  {
    type = "unit",
    name = "rus_rifleman_1",
    icon = "__base__/graphics/icons/small-biter.png",
    flags = {"placeable-player", "placeable-enemy", "placeable-off-grid", "breaths-air"},
    max_health = 15,
    order = "b-b-a",
    subgroup="creatures",
    minable = {hardness = 0.1, mining_time = 0.1, result = "rus_rifleman_1"},
    healing_per_tick = 0.01,
    collision_box = {{-0.5, -0.5}, {0.5, 0.5}},
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    attack_parameters =
    {
      type = "projectile",
      range = 12.5,
      cooldown = 35,
      ammo_category = "melee",
      ammo_type = make_unit_melee_ammo_type(6),
      sound = make_biter_roars(0.5),
      animation = rus_rifleman_1_runanimation(riflemanscale)
    },
    vision_distance = 30,
    movement_speed = 0.1,
    distance_per_frame = 0.4,
    pollution_to_join_attack = 200,
    distraction_cooldown = 300,
    dying_explosion = "blood-explosion-small",
    dying_sound =  make_biter_dying_sounds(1.0),
    working_sound =  make_biter_calls(0.7),
    run_animation = rus_rifleman_1_runanimation(riflemanscale)
  },
  {
		type = "item",
		name = "rus_rifleman_1",
		icon = "__base__/graphics/icons/small-biter.png",
		flags = {"goes-to-quickbar"},
		subgroup = "creatures",
		order = "a",
		stack_size = 100,
		place_result = "rus_rifleman_1",
	},
	{
		type = "recipe",
		enabled = true,
		ingredients = {
			{ "copper-cable", 1 }
		},
		name = "rus_rifleman_1",
		requester_paste_multiplier = 4,
		result = "rus_rifleman_1",
		result_count = 1
	}
}

Petrenko
Inserter
Inserter
Posts: 32
Joined: Mon Mar 20, 2017 1:10 pm
Contact:

Re: Cut off Graphics

Post by Petrenko »

Heyho,

i duplicated the unit to spawn as an enemy for my mod and that got no cut off edges.

Where can i find the cropcache.dat? I guess this could be the solution.

Edit: Nevermind. Found it. And worked. I wasn't aware this even existed. I'm an idiot. Thank you very much!

Post Reply

Return to “Modding help”