Page 1 of 1

Change on_pre_build for power poles built by dragging

Posted: Thu Jan 28, 2021 8:56 pm
by PFQNiet
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.

Re: Change on_pre_build for power poles built by dragging

Posted: Thu Jan 28, 2021 10:22 pm
by Rseding91
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.