LuaSurface::find_entities_filtered has unexpected interactions with empty table arguments

Post Reply
braxbro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sun Jan 01, 2023 2:54 am
Contact:

LuaSurface::find_entities_filtered has unexpected interactions with empty table arguments

Post by braxbro »

I recently encountered a bug where I was passing an empty table ({}) to the name argument of LuaSurface::find_entities_filtered in my mod Drills of Drills.

This had some unexpected, but not incomprehensible, undocumented behavior (though it did take me three versions of the mod to pin down what was happening) where the function ignored the argument entirely, rather than treating it as a list of zero allowed values and finding nothing.

I think this should probably be noted on the array-accepting arguments to save others the headache in the future.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaSurface::find_entities_filtered has unexpected interactions with empty table arguments

Post by Bilka »

Thanks for the note, I added a description to the affected parameters for the next release (1.1.106). Affected by this are:
name, ghost_name, type, ghost_type in find_entities_filtered and count_entities_filtered.
name in find_tiles_filtered and count_tiles_filtered.

Warning: This behaviour will change in 2.0: Then the more expected will happen, where giving an empty array for these field means nothing matches (unless the filter is inverted, of course).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Resolved Requests”