Page 1 of 1

given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 4:44 pm
by qqwertt
So I'm making a glorified loader with a large size, the sprite size is exactly 300x100.
Image
This is rotator.png (placeholder)
Image
This is my code for the entity

Code: Select all

{
      name="cargo-rotator",
      type="loader-1x1",
      filter_count=1,
      structure={
        direction_in={filename="__QwrtMod__/graphics/entity/rotator.png",size={300,100}},
        direction_out={filename="__QwrtMod__/graphics/entity/rotator.png",size={300,100}},
      },
      belt_animation_set={
        animation_set={direction_count=20,frame_count=1,filename="__QwrtMod__/graphics/entity/rotator.png",size={300,100}},
      },
      speed=8,
      icon="__QwrtMod__/graphics/placeholder.png",
      icon_size=64,
      collision_box={{-2.4,-0.4},{2.4,0.4}},
      selection_box={{-2.4,-0.4},{2.4,0.4}},
      placeable_by={item="cargo-rotator",count=1},
      flags={"placeable-neutral","player-creation"},
      minable={hardness=0.2,mining_time=0.5,result="cargo-rotator"},
    }

Re: given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 5:44 pm
by Hiladdar
In this case the clue is in the error message, ... top-0x100, right_bottom=300x200, ... followed by ... right_bottom=300x100 ...

The mismatch between what the system expects and what is provided.

When working in belts, I would recommend that you also take a look at the functions which are called by the entity definition of the belt. The command:

Code: Select all

belt_animation_set={
        animation_set={direction_count=20,frame_count=1,filename="__QwrtMod__/graphics/entity/rotator.png",size={300,100}},
      },
is a function call to common function used to define animation for belts. It could be that something is being passed from your entity definition to this function that the internal code does not like.

Hiladdar

Re: given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 5:44 pm
by kirazy
Your issue is with belt animation set. You're using an image with one direction but specify 20. So it's looking for an image 2000 pixels tall. You should use the belt sprite sheet here anyways, not your loader prototype.

Re: given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 6:06 pm
by qqwertt
that worked, thanks!!

Re: given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 6:41 pm
by kirazy
Also if you're making a larger loader, why use the loader-1x1 prototype and not the loader prototype?

Re: given sprite rectangle outside actual sprite size??

Posted: Fri May 22, 2020 9:16 pm
by darkfrei
You can use the same picture for all of expected sprites, just use the stripes:
(example from Burner Offshore Pump)

Special multiplication function:

Code: Select all

function make_stripes (count, filename)
	local stripe = {filename=filename, width_in_frames = 1, height_in_frames = 1}
	local stripes = {}
    for i = 1, count do
      stripes[i] = stripe
    end
  return stripes
end
Code from animation:

Code: Select all

local layer =
{
  stripes = make_stripes (8*4, dir .. "offshore-pump_north.png"),
  priority = "high",
  frame_count = 32,
  animation_speed = 0.25,
  width = 48,
  height = 84
}
The code makes same picture for every sprite.