Text assets
Text-asset patches change JSON-backed game content while it is loaded. They can edit existing definitions or add new content without replacing the complete source asset.
Common targets include parts, resources, planets, science definitions, missions, tech nodes, variants, and audio definitions.
Getting started
Start with Getting Started for the patch-file layout, editor support, and a first working patch.
Core Concepts explains the patch lifecycle, asset targeting, callbacks, features, dependencies, ordering, JSON values, configuration, and pm_summary.log.
APIs and typed modules
Generic JSON API patches any supported JSON-backed asset directly.
Typed Modules provide helpers for parts, missions, planets, resources, science, V-SwiFT variants, and audio.
Advanced Topics covers shared Lua modules, cross-mod compatibility, C# extensions, converters, and caching.
Reference contains the LuaPatch cheat sheet, enum values, and glossary.
Script globals
Patch scripts receive several useful globals:
PMregisters patches through APIs such asPM.Parts:Patch(...),PM.Planets:Patch(...), andPM.JSON:Patch(...).Jcreates JSON values that cannot be represented directly by ordinary Lua tables.ModIdidentifies the current mod.Locationprovides the patch location.Configreads the mod's configuration.CampaignConfigreads the settings that each campaign keeps.Featuresreads the active feature set.Enabledtells whether the mod is on in the active feature set.Logwrites diagnostic messages.
Use Features and Enabled only in runtime code. To gate patches, use :Feature.
See Working with JSON, File layout and discovery, and Config integration for details.
Minimal example
This patch finds the part named eva_kerbal and changes its crash tolerance:
PM.Parts:Patch("KerbalImpactToleranceFix")
:Named("eva_kerbal")
:Do(function(part)
part.crashTolerance = 30.0
end):Patch gives the patch a stable name, :Named selects the target, and :Do applies the change.