Page 1 of 1
placed_item in on_built_entity/on_robot_built_entity
Posted: Tue Aug 16, 2016 7:17 pm
by mknejp
Is it possible to add the field "placed_item" to the event data of "on_built_entity" and "on_robot_built_entity" if that information is available?
The rationale for this is being able to return the item used to build it if placing the entity fails for some mod-specific reason after the fact. Since there are multiple items that can be placed for an entity it's not reliably possible to return exactly the same item type.
Re: placed_item in on_built_entity/on_robot_built_entity
Posted: Tue Aug 16, 2016 9:10 pm
by aubergine18
+1 from me. Currently I'm having to keep checking what player has in their hand and cache that so if the entity built event gets fired I know what item was used (but in this context, only if it was player who built it - I still have no clue what item a robot used without doing lots of extra digging).
I was going to suggest a method on entities something like someEntity.get_item_used_to_create() but then realised that increasingly mods are creating multiple entities when an item is placed (the concrete lamppost mod is a good example). As such, the only reliable point at which we could get details about what item was used to create the entity is in those events as described in OP.
Re: placed_item in on_built_entity/on_robot_built_entity
Posted: Wed Aug 17, 2016 2:29 pm
by aubergine18
If you dig through to an entity prototype, you can find items used to create the entity:
http://lua-api.factorio.com/latest/LuaE ... place_this
Looks like a list of any item that can be used to place the entity. Problem is, there is no indication of which specific item was used (usually there will only be one such item so possibly not that big a problem?)
Re: placed_item in on_built_entity/on_robot_built_entity
Posted: Wed Aug 17, 2016 3:25 pm
by Rseding91
Factorio doesn't properly handle multiple items able to build the same entity. It always defaults to the first item if there are more than 1 that can build a given entity.
So, at the moment if there's an entity built the game will only ever know that "it was either built from the first item that builds this or I have no idea".