LuaEntity::revive() loses information about complex item-on-ground

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 471
Joined: Sun May 21, 2017 6:28 pm
Contact:

LuaEntity::revive() loses information about complex item-on-ground

Post by Therax »

LuaEntity::revive() returns a dictionary of item-name -> count for any item-on-ground entities that overlap the collision box of the newly-revived entity. If some of the item-on-ground entities contain complex stacks (tool, blueprint, armor, item-with-inventory, etc.) then any internal state is lost.

Proposal:

Have LuaEntity::revive() return a temporary LuaInventory, along the lines of the "buffer" provided in the on_player_mined_entity event. This would allow a mod to traverse a set of actual LuaItemStacks and put them into some other inventory (player, chest, robot, etc.), or to spill them onto the ground as new item-on-ground entities at a non-colliding position.

At the end of the currently running event handler, end of the tick, etc., Factorio would then dispose of the temporary inventory and any remaining contents.

Alternate or Supplementary Proposal:

A new option for LuaEntity::revive: teleport_colliding_items: boolean. If set to true (would be nice as the default in most use cases, I think?), instead of returning items to the caller, teleport any colliding item-on-ground entities to a non-colliding position.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Post Reply

Return to “Modding interface requests”