Hi,
I'd like to have an 1x1 entity (container type) that I could make visible or invisible, but always selectable/operable.
Is it possible ? How would you do this ?
Invisible/visible but still selectable entity ?
Re: Invisible/visible but still selectable entity ?
No, it's not directly possible because that is stored in the entity prototype.
The workaround would be to have two identical entities, except one has a transparent image.
Whenever you wanted to switch visibility you'd need to remove one chest and place another, copying the contents.
Something like (as I already had this coded sometime ago)
The workaround would be to have two identical entities, except one has a transparent image.
Whenever you wanted to switch visibility you'd need to remove one chest and place another, copying the contents.
Something like (as I already had this coded sometime ago)
Code: Select all
function replaceChest(sourceChest, targetChestName)
local inv = sourceChest.get_inventory(defines.inventory.chest)
local entity = sourceChest.surface.create_entity{
name = targetChestName,
position = sourceChest.position,
force = sourceChest.force,
bar = inv.getbar()}
if inv.getbar() == #inv then
entity.get_inventory(defines.inventory.chest).setbar()
end
for i = 1, #inv do
entity.get_inventory(defines.inventory.chest)[i].set_stack(inv[i]);
end
sourceChest.destroy()
end
Re: Invisible/visible but still selectable entity ?
OK, that's what I wanted to avoid, but if we have no choice...daniel34 wrote:No, it's not directly possible because that is stored in the entity prototype.
The workaround would be to have two identical entities, except one has a transparent image.
Whenever you wanted to switch visibility you'd need to remove one chest and place another, copying the contents.

My mods on the Factorio Mod Portal 
