Page 1 of 1

[2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 3:30 am
by PennyJim
Now, there's a pretty solid argument that this is an interface or feature request instead. I won't be upset if it just gets moved

If you hover over a chest, and run this command. The original chest will get destroyed (left on the ground).

Code: Select all

/c
local entity = game.player.selected
entity.surface.create_entity{
  name = "entity-ghost", inner_name = "steel-chest",
  position = entity.position,
  force = entity.force,
  fast_replace = true
}
08-17-2025, 21-27-37.png
08-17-2025, 21-27-37.png (157.12 KiB) Viewed 217 times
While it makes sense (why I think you could argue it's not a bug), I think the behavior that would make more sense is it marking the container for deconstruction. That is the behavior of the player 'placing' a ghost entity afterall. My argument for it being a bug, is that it's an side effect of 117533, or the enabling of fast replacing with ghosts.

At a minimum, I request that entities already marked for deconstruction are ignored in this.. It's causing a pretty bad bug in our mod Wide Containers and a workaround seems incredibly jank and annoying to develop.

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 6:45 pm
by kryojenik
I think that does exactly what it says on the tin. To emulate pasting a ghost upgrade over an existing entity you want to do:

Code: Select all

local entity = game.player.selected
entity.order_upgrade{
  target = "steel-chest",
  force = "entity.force",
  player = game.player
}
Now, if you are wanting to brute force replace the iron chest with the ghost of a steel chest, add

Code: Select all

spill = false
to your create_entity call and it won't drop the chest on the ground.

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 9:05 pm
by PennyJim
The crux of my problem was that I was fast-replacing a ghost and it was affecting the real entity.

I was not aware of `order_upgrade` (though I should've expected it to exist), and some quick testing shows that it is in fact instant on ghosts.
With a bit of "if ghost then" logic, this should be fixed... Thanks for pointing out a blindspot of mine <3


Moderators, feel free to either move it to "Not A Bug" or "Modding Help"

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 9:17 pm
by PennyJim
Oh wait nvm... `order_upgrade` doesn't work on ghosts
I just got my wires crossed while testing and forgot which entity I was fast-replacing and which one I had the event upgrade the ghost to

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 9:23 pm
by Rseding91
order_upgrade most certainty does work on ghosts.

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 9:24 pm
by PennyJim
Then... What am I doing wrong..? It's returning false
(though maybe this kinda conversation should move to the discord which can move faster)

Edit: Wait, I'm sure it's related to prototype stuff and `next_upgrade`..?
Edit 2: Or maybe it's the fact that I'm trying to go from ghost assembler to ghost container.. That's definitely it

Re: [2.0.64] Ghost fast replacing will directly replace entities

Posted: Mon Aug 18, 2025 9:33 pm
by Rseding91
Yeah there is no upgrade from that entity to that entity. If that's what you want to do, you have to destroy the old one and put a new one in place.