Page 1 of 1

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

Posted: Wed Apr 03, 2019 11:15 pm
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.