[2.1.12] Erroneous error with surface.create_entity() placing CarPrototype entity ghost
Posted: Mon Jul 27, 2026 12:13 am
This bug interacts with PlanetsLib's entity replacement system when creating entity replacement rules for Car Prototypes. Typically, when placing an entity on a planet with a replacement rule for that entity and planet, replace_entity() checks if the entity is a ghost by checking if "entity.name == "entity-ghost". If this is true, the entity that replaces the old entity is also an entity ghost. When placing a non-ghost vehicle, this function works perfectly, because it was designed with all LuaEntities in mind. When placing a vehicle entity ghost, replace_entity() detects that the ghost has the name "entity-ghost", and so places as an entity ghost, but when placing the new entity, Factorio throws the error "[vehicle-name] can not be part a entity ghost." At best, this error is not very descriptive of the issue, because CarPrototypes can be entity-ghosts, because this replacement would not be made an entity ghost if the entity it caught was not an entity ghost, and at worst, it's erroneously throwing an error that it should not be throwing.
One possible issue I considered is that because the newly placed CarPrototype is being placed in the location of an existing CarPrototype without immediately deleting the old entity, something completely possible with static entities, the game fails to place the new CarPrototype. To test this, I moved the old entity's position 100 units each direction before placing the new entity, but that did not change the error. The only explanation that makes sense is that this error is an artifact from before CarPrototype entity-ghosts were possible.
To reproduce:
1. Download this debug build of PlanetsLib. https://github.com/danielmartin0/Planet ... eplacement
2. Download this debug build of Muluna. https://github.com/nicholasgower/planet ... nated-fuel
3. Start a game with both mods loaded.
4. To test the PlanetsLib entity replacement system on vehicles, place a car on Muluna in cheat mode. It will place correctly, replacing the placed car with a Muluna-exclusive variation with different fuel categories.
5. If desired, test the entity replacement system for static entities by placing a rocket silo on Muluna. It will place correctly, replacing the placed rocket silo with a Muluna-exclusive variation with increased lift weight. Do the same thing with a ghost rocket silo if also desired.
6. On placing any entities that trigger an entity replacement, the game prints two lines: Whether the old entity was an entity-ghost or not, and the arguments passed to surface.create_entity.
7. Place the same car as a ghost. The same entity replacement script will fire as in step 4, but on attempting to place an entity-ghost, the error described above will fire. Read the debug prints made in the game's console. It notes that the detected entity-ghost car is an entity-ghost, and that the newly placed car is also an entity-ghost.
I believe this crash is due to an outdated assertion from before vehicle ghosts were added to the game in 2.0.
One possible issue I considered is that because the newly placed CarPrototype is being placed in the location of an existing CarPrototype without immediately deleting the old entity, something completely possible with static entities, the game fails to place the new CarPrototype. To test this, I moved the old entity's position 100 units each direction before placing the new entity, but that did not change the error. The only explanation that makes sense is that this error is an artifact from before CarPrototype entity-ghosts were possible.
To reproduce:
1. Download this debug build of PlanetsLib. https://github.com/danielmartin0/Planet ... eplacement
2. Download this debug build of Muluna. https://github.com/nicholasgower/planet ... nated-fuel
3. Start a game with both mods loaded.
4. To test the PlanetsLib entity replacement system on vehicles, place a car on Muluna in cheat mode. It will place correctly, replacing the placed car with a Muluna-exclusive variation with different fuel categories.
5. If desired, test the entity replacement system for static entities by placing a rocket silo on Muluna. It will place correctly, replacing the placed rocket silo with a Muluna-exclusive variation with increased lift weight. Do the same thing with a ghost rocket silo if also desired.
6. On placing any entities that trigger an entity replacement, the game prints two lines: Whether the old entity was an entity-ghost or not, and the arguments passed to surface.create_entity.
7. Place the same car as a ghost. The same entity replacement script will fire as in step 4, but on attempting to place an entity-ghost, the error described above will fire. Read the debug prints made in the game's console. It notes that the detected entity-ghost car is an entity-ghost, and that the newly placed car is also an entity-ghost.
I believe this crash is due to an outdated assertion from before vehicle ghosts were added to the game in 2.0.