Skip to content

Tutorials

cheese3660 edited this page Dec 12, 2023 · 4 revisions

Simple Patching Tutorials

Changing the mass of a single part in the game

[TBD]

Adding a type of resource to a part that already has a resource container

[TBD]

Adding a simple module to a part

[TBD]

Changing the crew capacity of a part

Creating a new resource

[TBD]

Creating a new recipe

[TBD]

Intermediate Patching Tutorials

Increasing the crew capacities of a part

[TBD]

Replacing a resource in a part

[TBD]

Adding a module to all parts that have a certain module

[TBD]

Increasing the crew capacity of all crewed parts

[TBD]

Adding PAM overrides for modules added to parts

So, you've added a module to your part, but you want it to show up in the PAM (Part Action Manager), as this does not happen by default. For this you want to add the following after the part where you add your modules

:parts ... {
    // Add the modules here

    
    PAMModuleVisualsOverride: +[
        {
            PartComponentModuleName: "...", // This is the module (usually of the form PartComponentModule_etc...) you want to add to the PAM of (e.g. PartComponentModule_ResourceConverter)
            ModuleDisplayName: "Your/Localized/Name", // This is the localization key of your modules PAM name
            ShowHeader: true, // Whether or not you want to show the header in the PAM
            ShowFooter: false // Whether or not you want to show the footer in the PAM
        }
        // You can add more modules by adding more comma separated blocks like above
    ];
    // If you wish to change how your module is sorted as well
    PAMModuleSortOverride: +[
        {
            PartComponentModuleName: "...", // This is the module (usually of the form PartComponentModule_etc...) you want to change the sorting of (e.g. PartComponentModule_ResourceConverter)
            sortIndex: 40 // This is the sort index in the PAM for your part, you have to fine tune this yourself, 40 is a good starting point
        }
        // You can add more overrides by adding more comma separated blocks like above
    ];
}

Advanced Patching Tutorials

Capturing values from modules of part(s) that have a specific module and using that value

There may be times where you want to add a module whose values depend on those in another module, or only if it has another module and a value in that module is above a specific number. For this you are going to want to use capture selectors, a variant of the .class selector meant for you to run code in the selector to add variables to the current scope and the like. The syntax for this selector is .class:[...] where ... is a semicolon separated (and terminated) list of statements running inside the "scope" of the module. To put this into use in an example for the purposes of the tutorial, we are going to capture the communication range of parts that have an antennae, and add a custom module with this communication range.

// This is going to be a part based selection
:parts {
    // Now let's do our "class capture", the .Module_DataTransmitter is the module for an antenna
    .Module_DataTransmitter:[
        $commRange: $$CommunicationRange; // And this is our capture, where we are capturing the object local value $$CommunicationRange from the Antenna module, and storing it in a scope local variable of $commRange
    ] {
        // In this scope $commRange is accessable, but $$CommunicationRange is not
        // Add the module like usual
        +Module_Test {
            // And the data
            +Data_Test {
                // Setting the value of Test inside the data to our captured value
                Test: $commRange;
            }
        }
    }
}

Patching JSON files that aren't of the default loaded rulesets

[TBD]

Clone this wiki locally