In-place fast_replace for create_entity

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
duskwuff
Inserter
Inserter
Posts: 23
Joined: Wed Aug 15, 2018 1:36 am
Contact:

In-place fast_replace for create_entity

Post by duskwuff »

Currently, calling LuaSurface.create_entity with fast_replace=true will always mine the old entity, either to a player's inventory or to the ground under the old entity. It would be great if there were a flag to disable this behavior so that fast_replace can be used to swap out an entity in place without side effects.

By way of example: my PassiveRadar mod allows players to toggle radars between two radar prototypes, one of which doesn't scan beyond its vision range. In early versions of the mod, I used create_entity with fast_replace to avoid having to copy properties from the old entity to the new one, but that ended up either granting the player radar items when toggling radars, or dropping those items on the ground under the radar. The current version of my mod instead has to laboriously save a bunch of properties from the old entity, destroy it, and create a new entity with the saved properties - and radars are relatively simple; copying all of the configuration for something more complicated like an assembler or train would be even harder.
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 148
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Re: In-place fast_replace for create_entity

Post by PennyJim »

If it can be made a "mode" type parameter where you can make it mark the replaced entity for deconstruction instead, then it could be manually destroyed without letting the user (or their bots) have a chance to actually mine it.

This would also be a possible fix for a bad bug I have in my mod that's much easier than stopping using fast replace and instead copying the circuit connections over In Lua. In fact I might like this solution more instead of my other request 131418
Rseding91
Factorio Staff
Factorio Staff
Posts: 16215
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: In-place fast_replace for create_entity

Post by Rseding91 »

You can simply set "spill" to false to get the behavior you want.
If you want to get ahold of me I'm almost always on Discord.
duskwuff
Inserter
Inserter
Posts: 23
Joined: Wed Aug 15, 2018 1:36 am
Contact:

Re: In-place fast_replace for create_entity

Post by duskwuff »

Ooh - okay, I didn't realize that option applied here. Thanks.
Post Reply

Return to “Modding interface requests”