When dragging a power pole, on_pre_build is fired for every position that the player's cursor moves over, without regard for whether a power pole is actually built. There doesn't appear to be any way in Lua to detect whether the placement will result in a power pole being built.
I can work around this by "delaying" the event and checking if an entity was actually created, but this is a very dirty hack and it would be nice to have a "proper" way to detect this.
Change on_pre_build for power poles built by dragging
Re: Change on_pre_build for power poles built by dragging
on_pre_build is exactly what this is intended to cover. If you want to know when something is actually built you listen to https://lua-api.factorio.com/latest/eve ... ilt_entity
There are any number of reasons why building may not happen after pre_build is fired.
There are any number of reasons why building may not happen after pre_build is fired.
If you want to get ahold of me I'm almost always on Discord.