find_entities_filtered searching for multiple names at once

Post Reply
keyboardhack
Filter Inserter
Filter Inserter
Posts: 478
Joined: Sat Aug 23, 2014 11:43 pm
Contact:

find_entities_filtered searching for multiple names at once

Post by keyboardhack »

Currently i have a mod that has to search the whole map for 8 different entities which each has a different name. Currently this is done by calling find_entities_filtered 8 different times with a different name each time. On large maps this takes more than 16ms. The goal of this interface request is to add an interface that can reduce this lag by only calling a single function to get the entities.

Currently the commands look like this:

Code: Select all

surface.find_entities_filtered({name = name1})
surface.find_entities_filtered({name = name2})
surface.find_entities_filtered({name = name3})
...
surface.find_entities_filtered({name = name8})
I would like to add another way of calling the function so it can take multiple names at once.

Code: Select all

surface.find_entities_filtered({name = {name1, name2, name3,..., name8}})
Last edited by keyboardhack on Tue May 01, 2018 12:45 am, edited 1 time in total.
Waste of bytes : P

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Nexela »

surface.find_entities_filtered {name = {"A", "b"}, type = {"C", "D"}

yada yada for
name :: string (optional)
type :: string (optional)
ghost_name :: string (optional)
ghost_type :: string (optional)
force :: string or LuaForce (optional)

All of those!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by eradicator »

Nexela wrote:surface.find_entities_filtered {name = {"A", "b"}, type = {"C", "D"}

yada yada for
name :: string (optional)
type :: string (optional)
ghost_name :: string (optional)
ghost_type :: string (optional)
force :: string or LuaForce (optional)

All of those!
Interesting. Does that pair or mix? I.e. will it find an A of type D, or only A's of type C?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Rseding91 »

Ok.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by eradicator »

Rseding91 wrote:Ok.
Do we get both pair and mix modes? Paired sounds more useful for OP.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Rseding91 »

eradicator wrote:
Rseding91 wrote:Ok.
Do we get both pair and mix modes? Paired sounds more useful for OP.
What?
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by eradicator »

Rseding91 wrote:
eradicator wrote:
Rseding91 wrote:Ok.
Do we get both pair and mix modes? Paired sounds more useful for OP.
What?
for something like

Code: Select all

surface.find_entities_filtered {name = {"house", "boat"}, type = {"assembling-machine", "car"}
Will it return car types named "house" or only car types named "boat" and assembling-machine types called "house"? I.e. if multiple lists of filters are specified, is the result the cartesian product of all the filters or not? Becaues for "searching multiple things with one api call" it would be better if it was not a cartesian product. Ofc that only works if all lists are the same length.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Klonan »

eradicator wrote:
Rseding91 wrote:
eradicator wrote:
Rseding91 wrote:Ok.
Do we get both pair and mix modes? Paired sounds more useful for OP.
What?
for something like

Code: Select all

surface.find_entities_filtered {name = {"house", "boat"}, type = {"assembling-machine", "car"}
Will it return car types named "house" or only car types named "boat" and assembling-machine types called "house"? I.e. if multiple lists of filters are specified, is the result the cartesian product of all the filters or not? Becaues for "searching multiple things with one api call" it would be better if it was not a cartesian product. Ofc that only works if all lists are the same length.
It is implemented as an array of filters, so you do

Code: Select all

surface.find_entities_filtered{
  name = {"car", "tank"},
  force = {"enemy", "player"}
}

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by eradicator »

Oh, so like...

Code: Select all

--Like this?
surface.find_entities_filtered{
 {name = 'car', force = 'enemy'},
 {name='tank', area = area_var},
  type='car',
 --etc
 }
--Or that?
surface.find_entities_filtered{
 {name = 'car', type='car', force = 'enemy'},
 {name='tank', type='car', area = area_var},
 --etc
}
I.e. is are common filter properties per table or can they be specified outside?

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Optera »

The API description should be expanded with an example of this multi filter search.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Rseding91 »

The filters work identical to before except now each section that supports an array is all or-ed inside that one filter.
If you want to get ahold of me I'm almost always on Discord.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: find_entities_filtered searching for multiple names at once

Post by Nexela »

Optera wrote:The API description should be expanded with an example of this multi filter search.
It was :P

name = string or array of strings

Post Reply

Return to “Implemented mod requests”