Get only deconstruct entities using find_entities_filtered

Place to get help with not working mods / modding interface.
Post Reply
pulsar9
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Jun 15, 2016 2:19 am
Contact:

Get only deconstruct entities using find_entities_filtered

Post by pulsar9 »

I was wondering if there was a way to use find_entities_filtered to find only entities that need to be deconstructed. I know that I could look through all of the entities and see if the to_be_deconstructed flag is set but this approach falls apart when the player is using something like the long reach mod. There could be thousands of entities to look through in that case. Also it doesn't have to be find_entities_filtered but it should efficiently get a list of entities that need to be deconstructed.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Get only deconstruct entities using find_entities_filtered

Post by Choumiko »

Depending on the specific use case http://lua-api.factorio.com/latest/even ... nstruction might be an alternative?

You could collect them in some global.variable and then process them in on_tick, and unregister the on_tick handler afterwards

pulsar9
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Jun 15, 2016 2:19 am
Contact:

Re: Get only deconstruct entities using find_entities_filtered

Post by pulsar9 »

Thank you for the reply. That is an alternative true, but I was more curious to know if there was some equivalent to find_entities_filtered that would get entities for deconstruction as a filter. Seems odd we can get ghost entities specifically but we can get deconstruction entities without incurring a large performance hit if you are playing with a mod like long reach. You can track them as they happen true, but it is a little more complicated than just saying "find me all deconstruction entities within reach" like you can with ghost entities using find_entities_filtered.

Post Reply

Return to “Modding help”