[Solved] Icon Changes When Placed

Place to get help with not working mods / modding interface.
Post Reply
Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

[Solved] Icon Changes When Placed

Post 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 1129 times
Looks wrong on the ground:
WrongOnGround.JPG
WrongOnGround.JPG (156.79 KiB) Viewed 1129 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 1126 times
Thank you for any insights.
Last edited by Job on Tue Oct 19, 2021 7:35 pm, edited 1 time in total.

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

Re: Icon Changes When Placed

Post by DaveMcW »

Entity icon is almost useless, it is only used in the map editor.

What you want is entity.picture.

Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

Re: Icon Changes When Placed

Post 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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [Solved] Icon Changes When Placed

Post by mrvn »

You should use a base image and a tint for the color.

Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

Re: [Solved] Icon Changes When Placed

Post 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.

Post Reply

Return to “Modding help”