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

Bugs that are actually features.
robot256
Smart Inserter
Smart Inserter
Posts: 1379
Joined: Sun Mar 17, 2019 1:52 am
Contact:

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

Post 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.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Rseding91
Factorio Staff
Factorio Staff
Posts: 17091
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

If this is not the behavior you want, simply set spill = false.
If you want to get ahold of me I'm almost always on Discord.
robot256
Smart Inserter
Smart Inserter
Posts: 1379
Joined: Sun Mar 17, 2019 1:52 am
Contact:

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

Post by robot256 »

Thank you! I forgot about that option.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Post Reply

Return to “Not a bug”