Skip to content

PartValidation Parameter

Jeremie Rossignol edited this page Aug 7, 2020 · 10 revisions

Parameter to provide validation over a vessel's parts. The PartValidation module can be used in two different modes - simple and extended. In the simple mode, simply provide the parameters to filter on, as in the following example:

PARAMETER
{
    name = PartValidation
    type = PartValidation

    // The name of the part to check for.  If multiple are specified, will
    // match on ANY of the parts listed.
    //
    // Type:      AvailablePart
    // Required:  No (multiples allowed)
    //
    part = mk1pod
    part = mk1-2pod

    // PartModule(s) to check for.  If multiple are specified, requires that
    // the given parts have ALL the partModules listed.
    //
    // Type:      string
    // Required:  No (multiples allowed)
    //
    partModule = ModuleReactionWheel
    partModule = ModuleSAS

    // Type of PartModule to check for.  Similar to partModule, but more
    // generic.
    //
    // Type:      string
    // Required:  No (multiples allowed)
    // Values (defined in ContractDefs):
    //     Antenna
    //     Battery
    //     Dock
    //     Generator
    //     Grapple
    //     Wheel
    partModuleType = Antenna

    // Extended PartModule check.  This is used to look for very specific part
    // module attributes.  The MODULE node may contain any attribute, and those
    // attributes will be matched against the part modules in the parts.  Each
    // attribute can be preceded by a label attribute, which will override the
    // logic that attemps derives an English name from the key (e.g
    // "experimentID" would become "Experiment ID").  The label also allows
    // localisation to be supported
    //
    // Required:  No (multiples allowed)
    //
    MODULE
    {
        name = ModuleScienceExperiment

        label = Experiment
        experimentID = mysteryGoo

        label = Other Thing
        otherThing = anotherAttribute
    }

    // Part manufacturer to check for.
    //
    // Type:      string
    // Required:  No
    //
    manufacturer = Kerbodyne

    // Part category to check for.
    //
    // Type:      PartCategories
    // Required:  No
    // Values:
    //   Aero
    //   Control
    //   Engine
    //   FuelTank
    //   Pods
    //   Science
    //   Structural
    //   Utility
    //
    category = Engine

    // Minimum and maximum count of matching parts.
    //
    // Type:      int
    // Required:  No (defaulted)
    // Default:   1 (minCount)
    //            int.MaxValue (maxCount)
    //
    minCount = 1
    maxCount = 10

    // Text to use for the parameter
    //
    // Type:      string
    // Required:  No (defaulted)
    // Default (maxCount: 0) = Part: <attributes>: None
    // Default (maxCount: int.MAXVALUE) = Part: <attributes>: At least <minCount>
    // Default (minCount: 0) = Part: <attributes>: At most <maxCount>
    // Default (minCount: maxCount ) = Part: <attributes>: Exactly <minCount>
    // Default (else): Part: <attributes>: Between <minCount> and <maxCount>
    //
    //title =
}

For the extended mode, parameters may be grouped into found types of nodes: FILTER, VALIDATE_ALL, VALIDATE and NONE. The blocks are applied in order. Typically, the FILTER blocks should be placed first.

  • FILTER - This will filter the list of parts down to the ones that match the given criteria.
  • VALIDATE_ALL - All remaining parts (after filtering) must match the given criteria.
  • NONE - None of the remaining parts (after filtering) should match the given criteria.
  • VALIDATE - Some of the remaining parts must match (only supports part, minCount and maxCount)

The FILTER, VALIDATE_ALL and NONE blocks can contain any of the attributes listed in the simple model, except minCount, maxCount and title. THe VALIDATE block can only contain part, minCount and maxCount.

Examples:

This validates that all engines must be manufactured by Rockomax, and there must be at least two of them.

PARAMETER
{
    name = PartValidation4
    type = PartValidation

    FILTER
    {
        category = Engine
    }

    VALIDATE_ALL
    {
        manufacturer = Rockomax
    }

    minCount = 2
}

This verifies that all parts that have a reaction wheel must not also have a SAS and must not be manufactured by Nightingale Engineering.

PARAMETER
{
    name = PartValidation
    type = PartValidation

    FILTER
    {
        partModule = ModuleReactionWheel
    }

    NONE
    {
        partModule = ModuleSAS
        manufacturer = Nightingale Engineering
    }
}

This verifies that the listed parts in the given quantities are present.

PARAMETER
{
    name = PartValidation
    type = PartValidation

    VALIDATE
    {
        part = fuelTank3-2
        minCount = 1
    }

    VALIDATE
    {
        part = largeSolarPanel
        minCount = 4
    }

    VALIDATE
    {
        part = cupola
        minCount = 2
        maxCount = 2
    }
}

The makes sure that the vessel has at least one part that has the mystery goo experiment module (which could be through the stock mystery goo canister or a modded part adding the mystery goo experiment.

PARAMETER
{
    name = PartValidation8
    type = PartValidation

    FILTER
    {
        MODULE
        {
            name = ModuleScienceExperiment
            experimentID = mysteryGoo
        }
    }

    minCount = 1
}
Clone this wiki locally