Extend placeable_by to other entity types

Things that already exist in the current mod API
User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 471
Joined: Sun May 21, 2017 6:28 pm
Contact:

Extend placeable_by to other entity types

Post by Therax »

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.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

Bilka
Factorio Staff
Factorio Staff
Posts: 3308
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Extend placeable_by to other entity types

Post by Bilka »

Therax wrote:I would like the ability to associate multiple entities with the same item for the purposes of [...] pipette usage.
You can already do that. See: https://github.com/Bilka2/Portals/blob/ ... ls.lua#L32 , pressing q on the portal will select the portal gun from the player's inventory. Same thing goes for portal-b.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 471
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Extend placeable_by to other entity types

Post by Therax »

Hmmmm, I feel sure I tried this with at least "container" entities. Back to prototyping!

Edit: I have no idea what I was doing wrong previously, because placeable_by appears to work exactly as I'd hope it would, including on "container" entities. Mea culpa!
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 “Already exists”