Control over how LuaEntity::set_recipe and copy_settings deal with removed items

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Shemp
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Mon Jan 19, 2026 6:51 pm
Contact:

Control over how LuaEntity::set_recipe and copy_settings deal with removed items

Post by Shemp »

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:
  • 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.
If the recipe is ordered to change via the circuit network, the items are always placed into the "assembling machine dump" inventory and the recipe doesn't switch in the machine until it is cleared out.

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 would like a way for scripts to access that native behaviour which would preserve all of the item information.

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. :lol:
Post Reply

Return to “Modding interface requests”