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.
However, here the function still returns true, despite no slots being filtered. This is the unexpected behavior of concern in this report.
Here the function returns false as expected, since chests cannot have filters set.
[Rseding91] [0.14.12] Unexpected LuaInventory.has_filters() result
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: [0.14.12] Unexpected LuaInventory.has_filters() result
has_filters is true if the inventory supports filters
See viewtopic.php?f=28&t=32521
See viewtopic.php?f=28&t=32521
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: [0.14.12] Unexpected LuaInventory.has_filters() result
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".Nexela wrote: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
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
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.