Extend placeable_by to other entity types
Posted: Tue Jan 23, 2018 10:00 pm
I would like the ability to associate multiple entities with the same item for the purposes of blueprinting and pipette usage. In base, straight-rail and curved-rail have this property, both being associated with the "rail" item, via the placeable_by entity prototype property. The placeable_by property does not appear to be read for non-rail entity types.
Use case:
Bulk Rail Loaders uses a proxy entity for initial placement, because I need to be able to handle rotation, but the final selectable entity needs to be of type "container." (There are other unselectable companion entities as well.) I'd like the railloader to be blueprintable, so at least one of its in-world entities needs an associated item, but this item can't be the same as the original item, since the original item places the rotatable proxy entity. Belt Buffer has very similar requirements and encounters similar issues.
Available workaround:
Have dummy items for the in-world entities, and then do fixup in on_player_setup_blueprint/on_player_configured_blueprint and on_player_pipette. For example, see Klonan's Belt Buffer mod: (https://github.com/Klonan/belt_buffer/b ... l.lua#L225)
This is less than ideal, particularly with on_player_pipette, since the "error" noise is played to the player (the dummy items will never be in inventory), and behavior does not reflect normal pipette behavior (no hand icon in the quickbar, cleaning the cursor does not return the item to the same quickbar slot.)
Improving the available workaround by allowing a mod to modify the item selected by pipette (Possibly by a writeable field in the on_player_pipette event? Perhaps a new on_pre_player_pipette event?) would be an alternative mod API change, but making placeable_by universal seems more consistent with existing Factorio behavior and would significantly reduce the required effort and room for error for mod authors.
Use case:
Bulk Rail Loaders uses a proxy entity for initial placement, because I need to be able to handle rotation, but the final selectable entity needs to be of type "container." (There are other unselectable companion entities as well.) I'd like the railloader to be blueprintable, so at least one of its in-world entities needs an associated item, but this item can't be the same as the original item, since the original item places the rotatable proxy entity. Belt Buffer has very similar requirements and encounters similar issues.
Available workaround:
Have dummy items for the in-world entities, and then do fixup in on_player_setup_blueprint/on_player_configured_blueprint and on_player_pipette. For example, see Klonan's Belt Buffer mod: (https://github.com/Klonan/belt_buffer/b ... l.lua#L225)
This is less than ideal, particularly with on_player_pipette, since the "error" noise is played to the player (the dummy items will never be in inventory), and behavior does not reflect normal pipette behavior (no hand icon in the quickbar, cleaning the cursor does not return the item to the same quickbar slot.)
Improving the available workaround by allowing a mod to modify the item selected by pipette (Possibly by a writeable field in the on_player_pipette event? Perhaps a new on_pre_player_pipette event?) would be an alternative mod API change, but making placeable_by universal seems more consistent with existing Factorio behavior and would significantly reduce the required effort and room for error for mod authors.