Page 1 of 1

[2.0.22] Set filter comparator to 'any quality' (= nil) not possible per lua

Posted: Thu Nov 28, 2024 1:52 pm
by picklock
If you want to set the comparator of a filter of an inventory slot to 'any quality', which as far as I understand is achieved with the value 'nil' for the comparator, this is not possible. The comparator value 'nil' is overwritten by Factorio with the comparator string '=' when the code is executed.

Code I tried with:

Code: Select all

local myContent = {
	name = "iron-plate",
	quality = "normal",
	comparator = nil
}
local myPlayer = game.get_player(1)
local myInventory = myPlayer.get_main_inventory()
myInventory.set_filter(1, myContent)
If you copy an ingame set filter via script to another itemslot, then the comparator is transferred correctly.

Re: [2.0.22] Set filter comparator to 'any quality' (= nil) not possible per lua

Posted: Thu Nov 28, 2024 2:20 pm
by boskid
any quality is achieved by not providing quality as it defaults to "any". Skipping comparator does not produce expected result because if comparator is missing it defaults to "=".

Re: [2.0.22] Set filter comparator to 'any quality' (= nil) not possible per lua

Posted: Thu Nov 28, 2024 2:52 pm
by picklock
Hi boskid!

Thank you for the explanation. Then I know how I can proceed to implement it. So from my point of view it's not a bug.