Page 1 of 1

Selection tool shows no icon for selected entity

Posted: Fri Jul 22, 2022 6:55 pm
by Pi-C
If you use a selection tool, you usually see icons of the selected entities. I've found that a selection tool I made will select a certain entity, but will not display its icon:
Left: selected "car" prototype. Right: selected "spider-vehicle" prototype.
Left: selected "car" prototype. Right: selected "spider-vehicle" prototype.
car.png (1.12 MiB) Viewed 909 times
Both entities look like the vanilla car (data.raw.car.car), but only the one on the left really is -- the other one is a "spider-vehicle" under the hood, created by Directional Movement Vehicles. That mod changes data.raw["item-with-entity-data"].car.place_result to DMV's own prototype.

The prototype browser shows that "items to place this" (I suppose that would be entity.prototype.placed_by) is nil for the vanilla car:
prototype.png
prototype.png (149.69 KiB) Viewed 909 times
Am I correct in supposing that no icon is shown for the selection because there is no item that can place the entity? Apparently, the car entity has an icon sprite -- why isn't that used instead? Is there anything I could do to get an icon of the vanilla car when it's selected with my tool? Having no visual feedback certainly is confusing, so I'd like to get it back.

The only solution I can think of is to make a copy of the item prototype (without a recipe to craft it, it should be hidden), and set its place_result to the vanilla entity. Is there a better way?

Re: Selection tool shows no icon for selected entity

Posted: Mon Aug 01, 2022 1:11 pm
by Bilka
Pi-C wrote: Fri Jul 22, 2022 6:55 pm Am I correct in supposing that no icon is shown for the selection because there is no item that can place the entity?
That is indeed exactly what that is checked. (And if there are items to place it, it only takes the first item for the icon.)
Pi-C wrote: Fri Jul 22, 2022 6:55 pm Apparently, the car entity has an icon sprite -- why isn't that used instead? Is there anything I could do to get an icon of the vanilla car when it's selected with my tool? Having no visual feedback certainly is confusing, so I'd like to get it back.

The only solution I can think of is to make a copy of the item prototype (without a recipe to craft it, it should be hidden), and set its place_result to the vanilla entity. Is there a better way?
I don't know the answer to this, but maybe a modding interface request could help.

Re: Selection tool shows no icon for selected entity

Posted: Mon Aug 01, 2022 1:44 pm
by Pi-C
Bilka wrote: Mon Aug 01, 2022 1:11 pm
Pi-C wrote: Fri Jul 22, 2022 6:55 pm Am I correct in supposing that no icon is shown for the selection because there is no item that can place the entity?
That is indeed exactly what that is checked. (And if there are items to place it, it only takes the first item for the icon.)
Thanks for your answer! Currently, I use this workaround:

Code: Select all

local items = data.raw["item-with-entity-data"]
for c, car in pairs(data.raw.car) do
  placed_by = car.placeable_by and car.placeable_by.item or car.name
  to_place = items[placed_by] and items[placed_by].place_result

  if to_place and to_place ~= placed_by then
    new_item = table.deepcopy(items[placed_by])
    new_item.name = "GCKI-dummy-item_"..new_item.name
    new_item.place_result = car.name
    data:extend({new_item})
  end
end
Pi-C wrote: Fri Jul 22, 2022 6:55 pm Apparently, the car entity has an icon sprite -- why isn't that used instead?
I don't know the answer to this, but maybe a modding interface request could help.
Thanks, we'll see about that. I've just made that request. :-)