Add filter to find_entities_filtered to find only entities with to_be_deconstructed = true

Post Reply
aaron311
Inserter
Inserter
Posts: 20
Joined: Sun Mar 22, 2020 2:30 am
Contact:

Add filter to find_entities_filtered to find only entities with to_be_deconstructed = true

Post by aaron311 »

Hi,

Issue summary:
I'd like to have a way to find only entities marked for deconstruction.

Details:
Currently to find to-be-deconstructed entities we have to find all entities then iterate them to filter the ones marked for deconstruction:

Code: Select all

      local entities = surface.find_entities{area=bounds, force=...}
      for _, e in pairs(entities) do
        if e.to_be_deconstructed() then 
          ...
        end
      end
This is of course slower than it could be.

Use case:
I'm experimenting with creating a mod that temporarily relocates the player to an alternative (but allied) force along with any entities that have construction requests within the player's roboport range. This effectively allows the player to hit a toggle and make his local roboport service the requests in his immediate vicinity despite possibly the nearby stationary network already trying to service those requests.

Related issues:
This request is very similar to the one already fulfilled here (only, for to-be-deconstructed entities instead of to-be-upgraded ones):
viewtopic.php?p=454093


Thank you for your consideration. Nice game BTW :-)

aaron311
Inserter
Inserter
Posts: 20
Joined: Sun Mar 22, 2020 2:30 am
Contact:

Re: Add filter to find_entities_filtered to find only entities with to_be_deconstructed = true

Post by aaron311 »

Just saw in the 0.18.20 release notes this is implemented. Thanks much! I'll be updating my mod this weekend to make use of this :-D

I assume this should be moved now to Implemented mod requests?

Thanks again!!

Post Reply

Return to “Implemented mod requests”