[2.0.64] Ghost fast replacing will directly replace entities

Bugs that are actually features.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Jan 18, 2023 3:49 am
Contact:

[2.0.64] Ghost fast replacing will directly replace entities

Post 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 209 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.
kryojenik
Inserter
Inserter
Posts: 49
Joined: Fri Jun 26, 2020 8:18 pm
Contact:

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

Post 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.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Jan 18, 2023 3:49 am
Contact:

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

Post 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"
Last edited by PennyJim on Mon Aug 18, 2025 9:23 pm, edited 1 time in total.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Jan 18, 2023 3:49 am
Contact:

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

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 16009
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

order_upgrade most certainty does work on ghosts.
If you want to get ahold of me I'm almost always on Discord.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Jan 18, 2023 3:49 am
Contact:

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

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 16009
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Not a bug”