Currently, there is no easy way to get the actual ItemStack that is being used for building an entity in a reliable way.
My use case here is copying the inventory of an item-with-inventory into the entity its being placed (a container) without loosing any state (item-with-inventory, blueprints, item-with-tags, labels, etc.)
My actual solution is to create the entity myself in on_put_item and use the player's cursor_stack to transfer the inventory to the created entity, but it has a major drawback:
I can't differentiate between the user placing a ghost and the user placing a real entity, which means a real entity will always be built even if the player intended to place a ghost.
For robots (on_robot_built_entity), the issue is worse since there is no way to access the real ItemStack at all (you only get the item name and its tags).
My suggestion is to add a new event parameter to on_robot_built_entity and on_built_entity. This parameter could either be a LuaItemStack or a LuaInventory (much like the buffer parameter to on_player_mined_entity) and it would contain the single item that was used to build the entity
Provide actual ItemStack in on(_robot)_built_entity
Provide actual ItemStack in on(_robot)_built_entity
Factorio Mod Portal Notifier - https://fac-notify.ml/
Cut and paste tools - https://mods.factorio.com/mods/mickael9/cut-and-paste
Portable Chests - https://mods.factorio.com/mods/mickael9/portable-chests
Cut and paste tools - https://mods.factorio.com/mods/mickael9/cut-and-paste
Portable Chests - https://mods.factorio.com/mods/mickael9/portable-chests
Re: Provide actual ItemStack in on(_robot)_built_entity
Ah, I guess I forgot about those events. I made the mined event useful in that it gives you the actual items but forgot about the built ones ![Smile :)](./images/smilies/icon_e_smile.gif)
I'll think about changing around the built events so they always give the item in the event. I don't know if it will make it into 0.15 though - it depends how complicated it ends up being making it work with validation that the stack is still valid.
![Smile :)](./images/smilies/icon_e_smile.gif)
I'll think about changing around the built events so they always give the item in the event. I don't know if it will make it into 0.15 though - it depends how complicated it ends up being making it work with validation that the stack is still valid.
If you want to get ahold of me I'm almost always on Discord.