Jump to content

[1.12.x] Filter Extensions (No localization)


linuxgurugamer

Recommended Posts

Originally written by @Crzyrndm, he is not active and gave permission for me to continue this.  Original thread is here:  https://forum.kerbalspaceprogram.com/index.php?/topic/93955-130-filter-extensions-304-jul-11/

 

With the stock editor now supporting custom filters in a reasonable way, creating more and better filters is the next logical step. However, the requirement for categories to be managed via code is just a terrible idea. Not to mention that there is no easy way to be compatible with anyone else. Filter Extensions allows the usage of .cfg files to create, edit, or delete all categories and sub-categories. It uses standard config files allowing for patches to be applied and dependencies allowed for using Module Manager.

Availability

License:
Icons and configs distributed with FE are under CC-BY-SA 4.0
Plugin is covered by GPLv3.

sBqMgMx.jpg
 

Configs and Icons

Configs and icons contributed by users are distributed with the download. Think something is missing and you can fill the gap? Just send the cfg's or icons my way :wink:

Docs are in the Filter Extensions Wiki

Spoiler

CATEGORY:NEEDS[B9_Aerospace]
{
    // Normal stuff: name, icon, colour, etc.
    name = B9 Aerospace
    icon = B9_Aerospace
    colour = #FFF0F0F0
    all = true
    // type = engine, stock <-- valid types. Engine will add subcategories of all engine variants (based on propellant combinations). stock must be specified to edit stock categories
	// value = replace <-- only valid value, only used with stock types
    // This is the template to be added to subcategories in this category. Subcategories in this category require parts to match one of the category Filters as well as their own unless using the "dont template" key
    FILTER
    {
        CHECK
        {
            type = folder
            value = B9_Aerospace
        }
    }
      // This is the subcategories listed by name. The number is the order they will appear in
    SUBCATEGORIES
    {
        list = 0,Pods
        list = 1,Fuel Tanks
        list = 2,Engines
        list = 3,Command and Control
        list = 4,Structural
        list = 5,Aerodynamics
        list = 6,Utility
        list = 7,Science
        list = Undefined // subcategories listed without an index will be added after all other subcategories are accounted for
        list = Undefined, dont template // the key "dont template" as the final element tells the subcategory to not use any of the category filters
	}
}

CATEGORY
{
	name = Filter by Function
	type = stock // If this isn't present it will go and make a new category
	value = replace
	// Tells it to clear all existing subcategories and completely redefine the subcategories present. If not used, the listed subcategories 
	// will just be added to the end of the list. Refer to the first spoiler for details on templating and addressing subcategories.
	// It's all the same
}

SUBCATEGORY
{
	// Same stuff as v1.x, but the category is no longer specified
	name = Air Intake
	icon = AirIntake
	FILTER
	{
		CHECK
		{
			type = moduleName
			value = ModuleResourceIntake
		}
	}
}

FilterRename
{
	name = LiquidFuel/Oxidizer, Rockets // name = <originalName>, <newName>
	name = ElectricCharge/XenonGas, Ions
	name = IntakeAir/LiquidFuel, Jets
	name = SolidFuel, SRBs
	name = MonoPropellant, MonoProp
}
FilterSetIcon
{
	icon = Rockets, EngineLFO // icon = <subCategoryName>, <iconName>
	icon = Ions, EngineIon
	icon = Jets, EngineJet
	icon = SRBs, EngineSolid
	icon = MonoProp, EngineMono
}
FilterRemove
{
	remove = subcategoryName
}

 

 

 

 

Some additional explanation of the cfg structure

Spoiler

All the things that make changes are in subdirectories of this folder. The "default" subdirectory is the one containing all the additions to Filter by Function, the rework folder has a different setup for the stock subcategories. All of the extra categories are individual .cfg's inside the "default" subdirectory. If you don't want it, delete it. The additional subcategories in Filter by Function are in the StockCategories.cfg (along with the improved cross section and resources categories) The replacement subcategories in Filter by Function are here. Just remove that folder if you want the stock layout

Filter Extensions uses two root config node types, CATEGORY and SUBCATEGORYCATEGORY nodes set category name, icon, colour of its subcategories, which subcategories are present and in what order, and can restrict what parts show up in their subcategories using the same syntax as the FE subcategoriesSUBCATEGORY nodes do most of the work wrt which parts are actually visible. They only have 4 possible entries: name and icon, "showUnpurchased" to override the plugin setting, and a set of FILTER nodes which decide which parts are visible. The subcategories are referenced by name when setting up a category and can be added to as many categories as you like.

tl;dr Once you have the name of a subcategory, just add it to the category of choice with a unique position (between 0 and 999. Duplicates will overwrite each other) and enjoy (NOTE: No position also works, it just gets added to the end of the list)

Writing a set of FILTER nodes to get the parts you want: Using the Electric Charge subcategory as an example, what I was aiming to do was improve on the stock Filter by Resource EC category by removing all the parts that often have a capacity of no significance (eg. engines with an alternator have one because of how the stock resource generation works, but that doesn't help the player looking for a battery)

The parts I wanted must have storage for the resource Electric Charge and must not be a part that only has EC storage as buffer (through experimentation this was determined to be engines, command modules, and generators) If you're familiar with any programming languages, that would typically be expressed something like this


result = hasResource("ElectricCharge") && !hasModule("ModuleCommand" || "ModuleEngines" || "ModuleGenerator");

Each CHECK node contains a single condition a part must pass to be visible. Each FILTER contains one set of conditions. If a part passes all the conditions in a FILTER, it will be visible.
Multiple FILTER nodes can be used when required (eg. Manned Command, the KerbalSeat module doesn't have a crew capacity of one or more so it needs to be checked for separately), although the comma separated lists have made that quite rare now

The majority of check types are listed in the first post, and I'll probably get some time this weekend to put together at least a full listing of them (alternatively, check the code that handles the type)

 

 

Using Near Future Propulsion's Argon Gas resource as an example

To remove a subcategory that you don't want to show, only specify the category (Filter by /*Insert here*/) and the title shown ingame for the offending subcategory

SUBCATEGORY
{
	category = Filter by Resource
	oldTitle = Argon Gas
}

 

To change the icon and title displayed, use the keys title and icon.

SUBCATEGORY
{
	category = Filter by Resource
	title = Wheels
	oldTitle = Argon Gas
	icon = R&D_node_icon_fieldscience

}

Acknowledgements
stupid_chris
 through RealChute which I originally used as a template. Getting started would have been much more difficult without that reference.
Nertea for the idea of the icon auto-loader
KaiserSoze - Adapting many icons, sharing configs, and reporting bugs

Mod icons are mostly adaptions of:

  • Part Catalog icons - originally by BlackNecro
  • Flags, manufacturer icons, and toolbar icons included with a mod. You can find links to the mods for all included icons here

To everyone that has contributed icons and/or cfg's to make others life easier - Your generosity is sincerely appreciated

Reporting Bugs

There are two types of bugs, so depending on what your problem is, there are different steps you may need to follow

Exceptions: Red text in the alt+f2 log, functionality breaks down completely, etc.
I need the information specified here

Functional issues: If the log shows no errors, then I need

  • The config you were trying to use
  • The mod that this applies to
  • A description of the expected behaviour
  • A description of the behaviour experienced

 

Edited by linuxgurugamer
Link to comment
Share on other sites

FYI, you have MM 2.8.1 and 3.0.1 both included in your "last successful artifacts" for Build #10 on Jenkins.

Quick question semi-offtopic: Are you moving all your adopted  (and otherwise) mods to Jenkins? I love having that available.  And a followup - is Jenkins capable of pushing the changes to Spacedock (and therefore CKAN) on a successful build for a release version?  If so, am I right in saying: Github & Jenkins setup looks like a good way to maintain things, reducing the time you spend on it to coding and testing, eliminating a lot of the overhead and fuss - correct?  Is it worth the time/effort to set it up?

Edited by Murdabenne
Link to comment
Share on other sites

40 minutes ago, Murdabenne said:

FYI, you have MM 2.8.1 and 3.0.1 both included in your "last successful artifacts" for Build #10 on Jenkins.

Quick question semi-offtopic: Are you moving all your adopted  (and otherwise) mods to Jenkins? I love having that available.  And a followup - is Jenkins capable of pushing the changes to Spacedock (and therefore CKAN) on a successful build for a release version?  If so, am I right in saying: Github & Jenkins setup looks like a good way to maintain things, reducing the time you spend on it to coding and testing, eliminating a lot of the overhead and fuss - correct?  Is it worth the time/effort to set it up?

Nuts, I thought I had fixed that, thanks.

And yes, as I work on mods, they get moved to Jenkins.

Re. Spacedock, the API is currently broken, if/when it's fixed, I'll add that as well

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
4 hours ago, linuxgurugamer said:

Due to Advanced Jet Engines changing things in a drastic way, I've had to add a new filter to Fiilter Extensions:

New release, 3.2.0.3

  • Added subcategory for ModuleEnginesAJEJet
  • Updated NamesAndIcons and 02_Engines to support the new AJE Jets

You are too awesome man.  That does give a new category that pulls in alot of the jet engines, but they also still appear in the nuclear engine category.  It does not catch things like KAX props that have AJE configs, those still only show in Nuclear Engines. 

Link to comment
Share on other sites

2 hours ago, eberkain said:

You are too awesome man.  That does give a new category that pulls in alot of the jet engines, but they also still appear in the nuclear engine category.  It does not catch things like KAX props that have AJE configs, those still only show in Nuclear Engines. 

Ah, well, I was concentrating on the jets and learning the FE syntax at the same time.

I'll get to that tomorrow, although I may need to add another icon for the props

Edited by linuxgurugamer
Link to comment
Share on other sites

14 hours ago, eberkain said:

You are too awesome man.  That does give a new category that pulls in alot of the jet engines, but they also still appear in the nuclear engine category.  It does not catch things like KAX props that have AJE configs, those still only show in Nuclear Engines. 

This problem is happening because AJE is removing the IntakeAir as a propellent.  FE displays the engines sorted by the propellents the use, and now jets only use liquid, as does nuclear engines.  The category is really engines that only use liquid, which up until now was only nuclear.

I’m working on a fix now

Link to comment
Share on other sites

New release, 3.2.0.3

  • Added subcategory for ModuleEnginesAJEJet
  • Updated NamesAndIcons and 02_Engines to support the new AJE Jets
  • Added new check to support checking the engine type
  • Added ability to filter on partial part name
  • Added configs for AJE jets and propellers
  • Added configs for Airplane+ propellers
  • Added new categories for engines:
    • Prop engines
    • Electric prop engines
  • Added some additional filters for the various Firespitter engines
Edited by linuxgurugamer
Link to comment
Share on other sites

On 1/12/2018 at 5:49 PM, eberkain said:

You are too awesome man.  That does give a new category that pulls in alot of the jet engines, but they also still appear in the nuclear engine category.  It does not catch things like KAX props that have AJE configs, those still only show in Nuclear Engines. 

Ummm, then you have a problem, because they should be in the Liquid Fuel category.  Nuclear engine should be just the nukes

Please show a screenshot and a log file

Link to comment
Share on other sites

  • 2 weeks later...

Is the filter by module list auto generated?   TweakScale module is not listed and would be handy to see a list of every part with tweakscale active for updating my tweakscale limited mod.  I looked through the configs and could not find anything about that defined filter by modules. 

Link to comment
Share on other sites

9 hours ago, eberkain said:

Is the filter by module list auto generated?   TweakScale module is not listed and would be handy to see a list of every part with tweakscale active for updating my tweakscale limited mod.  I looked through the configs and could not find anything about that defined filter by modules. 

Let me take a look, I think there is a way to filter by module. Keep in mind that it will show every part that has a tweak scale module installed.

Link to comment
Share on other sites

35 minutes ago, linuxgurugamer said:

Let me take a look, I think there is a way to filter by module. Keep in mind that it will show every part that has a tweak scale module installed.

Thanks, yeah I'm updating my tweakscale limited mod to eliminate tweakscale from everything but simple parts (tanks, structural, etc), That way all the complex parts will be able to be upgraded with KRnD.  

Link to comment
Share on other sites

Here you go:

https://www.dropbox.com/s/iiizhilzb4pb4ux/Tweakscale4FilterExtensions.zip?dl=0

Unzip it in the GameData directory, it's contents should merge with what's there already.

I used the icon from the Impact mod, which looks kind of like an explosion.  Click on it, and you will see all parts which have the TweakScale module

Edited by linuxgurugamer
Link to comment
Share on other sites

On 1/23/2018 at 9:32 PM, linuxgurugamer said:

Great.  I may expand this sometime, I can see people wanting it

Is it possible to do a combo filter?  Like showing every part with crew capacity, that does not have a connected living space module?   That would be a useful one to check on.   You know what would be really cool is being able to do a complex search like that in the search field at run time.  Like if I type +CREW -CLS into seach it would just magically show me all those parts.   :):):):) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...