Page 1 of 1

[Klonan] [1.0.0] Barreling icon code gen ignores icon_size if icons is defined

Posted: Mon Oct 19, 2020 9:43 am
by Pi-C
I've just had some serious trouble with the icon of a fluid I've defined. This is the important part of my definition:

Code: Select all

local extinguisherfluid = {
  type = "fluid",
  name = WT.fire_ex_fluid,
  icons = {
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-turret-bg.png",
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-turret.png",
      tint = WT.extinguisher_turret_tint,
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-fluid-bg.png",
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-fluid.png",
      tint = WT.fire_ex_fluid_tint,
    },
  },
  icon_size = 64,
  default_temperature = 25,
  […]
data:extend({ extinguisherfluid })
This does work perfectly for generating an icon for my fluid that will be displayed correctly. However, this is a fluid, so it can be barrelled. Barrelling recipes along with the icons are generated on the fly by the game. This is the icon I've got with the above code:
partial_barrelling_icon.png
partial_barrelling_icon.png (41.18 KiB) Viewed 3195 times
It took me a long time to figure out what was wrong. Finally, I solved the problem this way:

Code: Select all

local extinguisherfluid = {
  type = "fluid",
  name = WT.fire_ex_fluid,
  icons = {
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-turret-bg.png",
      icon_size = 64,
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-turret.png",
      icon_size = 64,
      tint = WT.extinguisher_turret_tint,
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-fluid-bg.png",
      icon_size = 64,
    },
    {
      icon = MOD_PIX .. "fluid/fire-ex-fluid-icon-fluid.png",
      icon_size = 64,
      tint = WT.fire_ex_fluid_tint,
    },
  default_temperature = 25,
  […]
data:extend({ extinguisherfluid })
This brought the expected result:
correct_barrelling_icon.png
correct_barrelling_icon.png (39.94 KiB) Viewed 3195 times
But my first version of the fluid definition was correct, according to the wiki:
icon_size

Type: Types/SpriteSizeType

Mandatory if icon_size is not specified inside all instances of Types/IconData inside icons. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
I think the comment should be extended:
Mandatory if icon_size is not specified inside all instances of Types/IconData inside icons. It must be specified inside the icons if it is used in a fluid definition. The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
Something like that, I'm not particular about the actual phrasing. But I guess the change could save many people a lot of time. :-)

Re: Insufficient explanation of icon_size

Posted: Mon Oct 19, 2020 10:36 am
by Bilka
That seems more like a bug in the barrelling icon generation code, it should not ignore the icon_size just because icons is defined. Moving to bug reports.

Re: [1.0.0] Barreling icon code gen ignores icon_size if icons is defined

Posted: Mon Oct 19, 2020 10:42 am
by Pi-C
Thank you! :-)

Re: [1.0.0] Barreling icon code gen ignores icon_size if icons is defined

Posted: Mon Oct 19, 2020 2:40 pm
by Klonan
Thanks for the report,

The barrel code is fixed for the next release, it will consider the fluid icon size,
and if not given, instead of defaulting to 32x32 icon size, it will throw an error.

Re: [Klonan] [1.0.0] Barreling icon code gen ignores icon_size if icons is defined

Posted: Mon Oct 19, 2020 2:50 pm
by Pi-C
Thanks, that should help!