Page 1 of 1

[0.17.8] LuaInventory.set_filter sets the filter even if a different type of item is in that slot.

Posted: Fri Mar 08, 2019 7:18 am
by Gergely
Step 1: Start a vanilla freeplay. Or put an item other than copper plate into the first slot of your inventory.
Step 2: Run this command: /c game.player.print(game.player.character.get_inventory(defines.inventory.player_main).set_filter(1,"copper-plate"))

What I expected to happen: A printout "false" because the content of the first slot of the inventory collides with the filter it would set.

What happens: A filter is set under the item in the inventory. The next time I remove the item, I can't put it back because of the filter even though the hand still shows up.

Re: [0.17.8] LuaInventory.set_filter sets the filter even if a different type of item is in that slot.

Posted: Fri Mar 08, 2019 7:21 am
by Gergely
The same is the case with "can_set_filter".

Running...
/c game.player.print(game.player.character.get_inventory(defines.inventory.player_main).can_set_filter(1,"copper-plate"))
...still prints out true even if there is an item of a different type in that slot.

Re: [0.17.8] LuaInventory.set_filter sets the filter even if a different type of item is in that slot.

Posted: Fri Mar 08, 2019 2:32 pm
by Rseding91
Thanks for the report however this is working correctly: the filter can be set regardless of what item is in the slot.

Re: [0.17.8] LuaInventory.set_filter sets the filter even if a different type of item is in that slot.

Posted: Fri Mar 08, 2019 5:57 pm
by Gergely
This used to work differently...

Under what conditions would the methods return false?

And what's the point of the item parameter in can_set_filter?

Re: [0.17.8] LuaInventory.set_filter sets the filter even if a different type of item is in that slot.

Posted: Fri Mar 08, 2019 6:52 pm
by Rseding91
Mainly for ammo/weapon inventories.