Add event for placing a blueprint over an entitiy

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
kajacx
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Mar 10, 2019 11:08 am
Contact:

Add event for placing a blueprint over an entitiy

Post by kajacx »

TL;DR
Add a new event (on_entity_blueprint_replace or something), that would be triggered when "pasting" over an entity with a blueprint.

What ?
The event should have, most importantly, the BlueprintEntity that is being pasted, and the existing LuaEntity that is being "replaced". It could be an array of pairs, or the event could be triggered for each individual entity. Even better if it would work for ghosts too (when placing a blueprint over a ghost).

Edit: adding a list of "final" blueprint entities (after rotation and with on-surface position) to the on_pre_build event would also work fine.

Why ?
I am making a mod that copies modules, and when the player places a blueprint with entities that have modules, the mod creates a logistic request to insert those modules into the existing entities from the blueprint entity. However, I need to manually compute the blueprint entity positions, which means re-implementing the blueprint placing logic that already exists in Factorio in a lua mod.

That is not only kind of inefficient (not to mention difficult), but is likely to have bugs/inconsistencies, considering all the possible options (vertical and horizontal flipping, rotations, rails, absolute/relative snapping, weirdly shaped objects like the offshore pump, etc.). So this event would make life easier for both the players (no inconsistencies) and mod makers (easier interaction with building over an entity with a blueprint).

Post Reply

Return to “Modding interface requests”