Control over how LuaEntity::set_recipe and copy_settings deal with removed items
Posted: Wed Jul 08, 2026 1:20 pm
When you change an assembling machine recipe using its GUI in-game, or copy/paste settings from another assembler, the game handles the items that were inside the machine in one of two ways:
LuaEntity::set_recipe and LuaEntity::copy_settings both delete the removed items from the game and return them as an array of ItemWithQualityCount, but this has some limitations:
That format doesn't include special item data such as:
I know that accounting for mods changing game state during recipe changes has been a source of trouble in the past - but I'm just curious why these functions are set up this way.
- If you're in character mode, it tries to put the items in your inventory, and spills them at your feet if some of them don't fit.
- If you're in Remote View, items that don't fit in the new recipe will enter the machine's trash inventory. Scripts cannot expand this inventory.
- In both of the above cases, items that are common to both recipes will stay where they originally were, but an ingredient will never move to a product slot.
LuaEntity::set_recipe and LuaEntity::copy_settings both delete the removed items from the game and return them as an array of ItemWithQualityCount, but this has some limitations:
That format doesn't include special item data such as:
- Durability
- Spoilage progress
- Tags
- Equipment
I know that accounting for mods changing game state during recipe changes has been a source of trouble in the past - but I'm just curious why these functions are set up this way.