PDA

View Full Version : SWADE - Missing Group filter for Individual Item Lists



Miglefin
April 23rd, 2019, 00:40
Would it be possible to either add group filters to the Item tables or have the Item filter selected in the main Item table automatically apply to the table views? This would allow us to have custom item tables for particular settings.

More info
When we select any of the individual item buttons (Item, Armor, Melee, Ranged, Vehicle) from the top of the Items screen we see handy table views showing all of the Items of that particular type; however there are no group filters to these views, also the group filter we set on the main Items screen does not apply to the table views.

What this means is that if you have a modified item list or items with the same name from different settings, we get duplicate items it the table views which cannot be filtered or removed without removing the modules. It also means that if we are playing a particular campaign (for example fantasy) our weapons lists, and items are cluttered with modern and futuristic items, which again cannot be easily removed.

Miglefin
May 14th, 2019, 18:57
Maybe I'm just missing something. Please see attached image 27334

As an example I have two different maces in the items list - One Listed under Medieval (SWADE) and the other under Hammers & Maces (Hellfrost). They are not identical, as a mace is twice as expensive in Hellfrost. I'm filtering my Items list to only show the Hellfrost Players Guide items and it shows one Mace, but there is no filter applied (or available) on the Melee Weapons tab.

What I'd like to do is set up my own Item List, and make only that available to the players but I'd also like to share the SWADE and Hellfrost players guide. If I create my own list, there will be 3 maces. Filtering would be the next best thing but does not help when looking at the tables (such as melee weapons...)

Trenloe
May 14th, 2019, 19:15
The "Melee Weapons" table is specifically designed to show all items of that type - there's no filtering as standard.

You could create your own "grouped list" (as it's referred to in FG) or maybe modify the standard filter on that grouped list - via an extension.

But this is all FG code - if you're willing to have a look, go to scripts\data_library_sw.lua in the SavageWorlds.pak ruleset file. Search for "weapon_grouped_title_meleeweapon" to get to the section where the melee weapon grouped list is defined. Note that there's a filter defined in:

aFilters = {
{ sCustom = "item_ismeleeweapon" }

Which, via the setCustomFilterHandler at the bottom of that file, runs the isMeleeWeaponItem function - maybe you could look at changing that filter in an extension? You could overwrite that function in the LibraryDataSW pacakge using some code such as this:

function onInit()
LibraryData.setCustomFilterHandler("item_ismeleeweapon", myMeleeWeaponFilter)
end

function myMeleeWeaponFilter(vRecord, vDefault)
-- Change to whatever you need to do your filter
local sTraitType = vRecord and DB.getValue(vRecord, "traittype")
return isWeaponItem(vRecord, vDefault) and StringManager.equals(sTraitType, "Melee") and not isVehicularItem(vRecord, vDefault)
end

Edit: you could probably use this API call to determine which module the record comes from: https://www.fantasygrounds.com/refdoc/databasenode.xcp#getModule with something like the following (I haven't tested this, so syntax might not be 100% correct):

function myMeleeWeaponFilter(vRecord, vDefault)
local sTraitType = vRecord and DB.getValue(vRecord, "traittype")
return LibraryDataSW.isWeaponItem(vRecord, vDefault) and StringManager.equals(sTraitType, "Melee") and not LibraryDataSW.isVehicularItem(vRecord, vDefault) and vRecord.getModule() == "Module name I want to filter on"
end

Trenloe
May 14th, 2019, 19:52
I've made a quick extension using the code I mentioned above - see attached.

I don't have any Hellfrost modules, so I've guessed (based off the screenshots on the store page) that the module name is "Hellfrost Players Guide" - you can change in the extension if you need to. I've left some debug code that writes to the FG console the name of the module for each item the filter checks - open the console using the \console chat command and you'll be able to see the exact name of the module for each item record the filter is checking.

Miglefin
May 14th, 2019, 20:01
Superb Trenloe, worked straight out of the gate. Will review and see how to extend to the Item, Armor, Ranged and Vehicle lists - but this is really excellent!

Trenloe
May 14th, 2019, 20:02
Superb Trenloe, worked straight out of the gate.
Woo hoo! :D

Miglefin
May 14th, 2019, 21:14
Your comments were great, this is the first time I've tried anything like this and I was able to modify also to filter for the ranged weapons and vehicular weapons. The Item and Armor lists look like a different format, so give them a shot later.

Miglefin
May 14th, 2019, 22:31
Hi Trenloe it looks like it works for all lists with the attached modified Ext file. Which just basically repeats what you had done for the weapons list for the item, armour, ranged and vehicular weapons lists. 27336

Thinking about it, the easier more flexible solution would be for the group (Category) drop down list at the top of the main Item window to automatically filter all of the item lists to the same Group as per the following screenshot. 27337

This would not restrict the players from selecting something from another list, but even in the EXT version they can select from any item from the main Item list.

I think it would be useful to code all sub-tables (Powers by Rank, Edges by Type, Races by Racial Abilities, Vehicles by Group, as well as Items by Item/Armor/Melee/Ranged/Vehicles) to be sorted the categories selected on the main tables.