PDA

View Full Version : aCustomFilters in data_library.lua



Mike Serfass
February 15th, 2023, 02:35
I'm attempting to add a new filter to the items list.

The comments in data_library.lua says

aCustomFilters = Optional. Table of custom filter table records

How do I pass that?

I'm setting other properties of the item record successfully. This works:


item_record_info = LibraryData.getRecordTypeInfo("item")
table.insert(item_record_info.aGMListButtons, "button_modification_list")


However, this does not:

table.insert(item_record_info.aCustomFilters, { ["Category"] = { sField = "catname" } })

I've tried every permutation of that line I can think of. It either fails to load with error message like

'}' expected near '='
with some random brace } 0 or ], and it doesn't matter where I put braces of any kind.

Or it loads the script but throws the same error when it runs

attempt to compare number with string

How do I declare

"Category"] = { sField = "catname" }
in

able.insert

Thanks

damned
February 15th, 2023, 03:18
try == instead of = possibly?
== compares and = sets

Moon Wizard
February 15th, 2023, 03:34
You're not adding the data in the same format as the underlying object expects it.

Depending on the ruleset, that field looks like this: (from 3.5E/PFRPG item record type)


aCustomFilters = {
["Type"] = { sField = "type" },
},


You'd need to modify your code to do something like this:


item_record_info = LibraryData.getRecordTypeInfo("item");
...
if not item_record_info.aCustomFilters then
item_record_info.aCustomFilters = {};
end
item_record_info.aCustomFilters["Category"] = { sField = "catname" };


Regards,
JPG

Mike Serfass
February 15th, 2023, 04:26
Thank you Moon Wizard!