Page 1 of 1

[2.1.9] Using script to fast_replace locomotive drops item on ground

Posted: Thu Jul 02, 2026 3:33 am
by robot256
What did you do?
1. Open a map with Quality mod enabled.
2. Place a normal Locomotive.
3. Select it and run the following command:
/c local e = game.player.selected; e.surface.create_entity{name="locomotive", quality="legendary", position=e.position, orientation=e.orientation, force=e.force, fast_replace=true}
What happened?
The locomotive is replaced by a legendary Locomotive. Also, a normal Locomotive item is dropped on the ground nearby.
What did you expect to happen?
I expected no item-on-ground to be produced. Using a script to fast-replace does not consume any items, so this becomes an item duplication bug. If I want to extract an item from the entity before replacing it, then I expect to use LuaEntity::mine() or another method.

This may actually be a modding interface request to disable the item creation during create_entity(). I realize that creating an item for the removed entity during fast-replace is how it works when a player does it, but that's expected because the player also uses an item to perform the replacement.

Re: [2.1.9] Using script to fast_replace locomotive drops item on ground

Posted: Thu Jul 02, 2026 2:53 pm
by Rseding91
If this is not the behavior you want, simply set spill = false.

Re: [2.1.9] Using script to fast_replace locomotive drops item on ground

Posted: Thu Jul 02, 2026 3:03 pm
by robot256
Thank you! I forgot about that option.