Missing layers documentation

Post Reply
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Missing layers documentation

Post by DaveMcW »

I had trouble automatically copying graphics from another mod because I didn't realize the layers property was optional.

Both of these are valid picture definitions:

Code: Select all

entity.picture = {
  filename = "__mod__/graphics/image.png",
  width = 32,
  height = 32,
}

entity.picture = {
  layers = {
    {
      filename = "__mod__/graphics/image.png",
      width = 32,
      height = 32,
    },
  }
}

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

Re: Missing layers documentation

Post by Bilka »

There are multiple sprite/animation types, sometimes even new graphic loading classes for just 1 entity, so you need to specify which type is missing 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
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Missing layers documentation

Post by eradicator »

As far as i understand you can use layers= in almost any node that expects graphics (even icons, though the syntax is different). And you can use stripes= in any place that expects filename=. So it's not really a special feature of picture=.

Via wiki search i can only find a short paragraph about layers:
https://wiki.factorio.com/Types/RotatedAnimation#layers
And reading it sounds like having layers= inside layers= would be vald. I've never seen that and i cant imagine how that would be useful/different from just one layers=. Any example for that? @Bilka.

Stripes also has only once sentence:
https://wiki.factorio.com/Types/Animation#stripes
From which it's difficult to guess how to use it. (Admittedly stripes is a feature that 99% of mods will never need.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: Missing layers documentation

Post by Bilka »

eradicator wrote:And reading it sounds like having layers= inside layers= would be vald. I've never seen that and i cant imagine how that would be useful/different from just one layers=. Any example for that? @Bilka.
I have not seen it used anywhere, I simply documented what would be possible from the perspective of the code. And from the perspective of the code it basically works like this (pseudo code):

Code: Select all

function loadRotatedAnimation(input)
  if input["layers"] then
    local layers = input["layers"]
    for _, layer in pairs(layers) do
      loadRotatedAnimation(layer)
    end
  end
  -- load everything else
end
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
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Missing layers documentation

Post by DaveMcW »


User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Missing layers documentation

Post by DaveMcW »

eradicator wrote:And you can use stripes= in any place that expects filename=
It only seems to work on Animation, not Sprite.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Missing layers documentation

Post by Rseding91 »

DaveMcW wrote:
eradicator wrote:And you can use stripes= in any place that expects filename=
It only seems to work on Animation, not Sprite.
It works for everything. It's nested inside the Sprite class constructor which is what every image loaded uses. Therefor: every image defined through Lua supports it.
If you want to get ahold of me I'm almost always on Discord.

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

Re: Missing layers documentation

Post by Bilka »

Rseding91 wrote:It works for everything. It's nested inside the Sprite class constructor which is what every image loaded uses. Therefor: every image defined through Lua supports it.
The other graphics use SpriteParameters, not Sprite. But that's besides the point, "stripes" isn't not loaded in the Sprite/SpriteParameters. You can find it being loaded specifically in Animation (and RotatedAnimation).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

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

Re: Missing layers documentation

Post by Bilka »

DaveMcW wrote:
Bilka wrote:you need to specify which type is missing documentation.
https://wiki.factorio.com/Types/Sprite
https://wiki.factorio.com/Types/RotatedSprite
https://wiki.factorio.com/Types/Animation
I have updated the documentation for all of these types.
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
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Missing layers documentation

Post by DaveMcW »

Thanks for fixing the wiki!
Bilka wrote:"stripes" isn't not loaded in the Sprite/SpriteParameters. You can find it being loaded specifically in Animation (and RotatedAnimation).
Any plans to fix stripes for Sprites?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Missing layers documentation

Post by Rseding91 »

DaveMcW wrote:Thanks for fixing the wiki!
Bilka wrote:"stripes" isn't not loaded in the Sprite/SpriteParameters. You can find it being loaded specifically in Animation (and RotatedAnimation).
Any plans to fix stripes for Sprites?
It's not broken. A single sprite has a maximum size and if you want to use a larger sprite you have to use layers and shift each sprite.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”