Page 1 of 1

[Solved] Icon Changes When Placed

Posted: Tue Oct 19, 2021 4:59 pm
by Job
I created a Warp Chest, which is just a modification of the Linked Chest. The mod loads, and it has the custom properties related to inventory size. But, when I place the item on the ground, it reverts icons back to the base model.

I have tried numerous approaches looking at different mods and going through these forums, as I sense I missing something obvious to others.

I am guessing this has to do with properly defining the item icon, but not the entity icon.

Current code is below:

Code: Select all

--item.lua

local WarpChest = util.table.deepcopy(data.raw["linked-container"]["linked-chest"])
WarpChest.name = "warp-chest"
WarpChest.minable.result = "warp-chest"
WarpChest.inventory_size = 80
WarpChest.icon = "__WarpChests-iterate-2__/graphics/icons/linked-chest-icon-light-red.png"
WarpChest.icon_size = 64

data:extend({
  WarpChest,
  {
    type = "item",
    name = "warp-chest",
    icon = "__WarpChests-iterate-2__/graphics/icons/linked-chest-icon-light-red.png",
    icon_size = 64, icon_mimaps = 4,
    subgroup = "storage",
    order = "a[items]-a[warp-chest]",
    place_result = "warp-chest",
    stack_size = 20
  },
  {
    type = "recipe",
    name = "warp-chest",
    enabled = true,
    ingredients =
    {
      {"iron-plate", 1},
    },
    result = "warp-chest"
  }
})
Screenshots:

Looks right in the inventory (red/rust tinted chest in invesntory and recipies):
CorrectInInventory.JPG
CorrectInInventory.JPG (189.13 KiB) Viewed 1395 times
Looks wrong on the ground:
WrongOnGround.JPG
WrongOnGround.JPG (156.79 KiB) Viewed 1395 times
Attached the icon file in case it helps.
linked-chest-icon-light-red.png
linked-chest-icon-light-red.png (9.28 KiB) Viewed 1392 times
Thank you for any insights.

Re: Icon Changes When Placed

Posted: Tue Oct 19, 2021 6:07 pm
by DaveMcW
Entity icon is almost useless, it is only used in the map editor.

What you want is entity.picture.

Re: Icon Changes When Placed

Posted: Tue Oct 19, 2021 7:35 pm
by Job
DaveMcW wrote: Tue Oct 19, 2021 6:07 pm Entity icon is almost useless, it is only used in the map editor.

What you want is entity.picture.
Thank you DaveMcW.

That got me on the right path.

For anyone who needs it in the future, the final working code was:

Code: Select all

--item.lua

local WarpChest = util.table.deepcopy(data.raw["linked-container"]["linked-chest"])
WarpChest.name = "warp-chest"
WarpChest.minable.result = "warp-chest"
WarpChest.inventory_size = 80
WarpChest.picture = 
  {
    filename = "__WarpChests-iterate-2__/graphics/icons/linked-chest-icon-light-red.png",
    size = 64,
    scale = 0.5
  }

data:extend({
  WarpChest,
  {
    type = "item",
    name = "warp-chest",
    icon = "__WarpChests-iterate-2__/graphics/icons/linked-chest-icon-light-red.png",
    icon_size = 64, icon_mimaps = 4,
    subgroup = "storage",
    order = "a[items]-a[warp-chest]",
    place_result = "warp-chest",
    stack_size = 20
  },
  {
    type = "recipe",
    name = "warp-chest",
    enabled = true,
    ingredients =
    {
      {"iron-plate", 1},
    },
    result = "warp-chest"
  }
})
Next step is to try looping the code to create several variants/colors.

Re: [Solved] Icon Changes When Placed

Posted: Wed Oct 20, 2021 2:36 am
by mrvn
You should use a base image and a tint for the color.

Re: [Solved] Icon Changes When Placed

Posted: Wed Oct 20, 2021 2:40 am
by Job
mrvn wrote: Wed Oct 20, 2021 2:36 am You should use a base image and a tint for the color.
That's my long-term plan. First I'm just trying to get iterating to work at all.