Page 1 of 1

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

Posted: Wed Oct 05, 2016 5:15 am
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 1301 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 1301 times
Here the function returns false as expected, since chests cannot have filters set.
Shot3.jpg
Shot3.jpg (781.72 KiB) Viewed 1301 times

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

Posted: Wed Oct 05, 2016 5:21 am
by Nexela
has_filters is true if the inventory supports filters
See viewtopic.php?f=28&t=32521

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

Posted: Wed Oct 05, 2016 5:26 am
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".

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

Posted: Wed Oct 05, 2016 8:16 am
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.

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

Posted: Wed Oct 05, 2016 8:38 am
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).