[Rseding91] [0.14.12] Unexpected LuaInventory.has_filters() result

This subforum contains all the issues which we already resolved.
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

[Rseding91] [0.14.12] Unexpected LuaInventory.has_filters() result

Post by Supercheese »

Referencing this function: http://lua-api.factorio.com/latest/LuaI ... as_filters

I had expected that this function would return true if an inventory has any filters currently set, and false if every slot is unfiltered. However, this is not the case, and the function still returns true on an inventory with no filters set. The following screenshots demonstrate the unexpected behavior:

Here the function returns true, as expected since there are filters set.
Shot1.jpg
Shot1.jpg (858.39 KiB) Viewed 1305 times
However, here the function still returns true, despite no slots being filtered. This is the unexpected behavior of concern in this report.
Shot2.jpg
Shot2.jpg (856.17 KiB) Viewed 1305 times
Here the function returns false as expected, since chests cannot have filters set.
Shot3.jpg
Shot3.jpg (781.72 KiB) Viewed 1305 times
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [0.14.12] Unexpected LuaInventory.has_filters() result

Post by Nexela »

has_filters is true if the inventory supports filters
See viewtopic.php?f=28&t=32521
Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: [0.14.12] Unexpected LuaInventory.has_filters() result

Post by Supercheese »

Nexela wrote:has_filters is true if the inventory supports filters
See viewtopic.php?f=28&t=32521
Ah, well, that addresses my confusion, but it still doesn't change the fact that the behavior is extremely unexpected, given the name of the function and the lack of documentation. The function should therefore be renamed to something like "supports_filters".
Loewchen
Global Moderator
Global Moderator
Posts: 10313
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: [0.14.12] Unexpected LuaInventory.has_filters() result

Post by Loewchen »

Renaming functions is quite problematic and would most likely not come before 0.15, but I'll keep this open for a dev to decide if its even worth it in this case.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16000
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14.12] Unexpected LuaInventory.has_filters() result

Post by Rseding91 »

What I can do is remove the current function and replace it with "supports_filters" and then add "is_filtered". That way there's no mistaken use and the names are more explicit. Anyone using the current "has_filters" simply would need to find->replace with "supports_filters" and they'd be done (minimal fix).
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”