Setting up your editor
You can write patches in any text editor, but this is not recommended. PatchManager has a large API, and without help you will be guessing at field names. The PatchManager Lua extension for VSCode gives you autocomplete, inline documentation, and type checking for the entire lua modding API. Set it up once and the rest of these docs become a lot easier to follow.
Install the extension
Install VSCode if you do not have it.
To install the editor extension, either:
Open https://marketplace.visualstudio.com/items?itemName=infinity-sys.pm-lua and click Install, or
Open the Extensions panel and search for PatchManager Lua (publisher
infinity-sys). Install it. It depends on the Lua language server extension (sumneko.lua) and will pull that in for you.
Open the folder where you write your patches as a VSCode workspace.
Configure the workspace
When you open a folder that contains Lua files, the extension offers to configure it. Accept, or run the command yourself:
Open the command palette (
Ctrl+Shift+P).Run PatchManager Lua: Configure Workspace.
That command does two things:
It drops the API stub files into
.pmlua/stubs/in your workspace and adds.pmlua/to your.gitignore, so the generated stubs do not end up in your repository.It configures the Lua language server: the right Lua runtime version, the
|lambda|syntax PatchManager scripts use, and the stubs folder as a library so everything resolves.
After that, open any .lua file and type PM. You should see the submodules (Parts, Planets, Missions, and so on) offered. Hover any method for its documentation.
What the stubs give you
The stubs are LuaLS definition files, one per area of the API. You will see their names referenced throughout these docs:
Stub | Covers |
|---|---|
|
|
| the JSON value you get in a |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| the enums (engine types, part categories, and so on) |
When a page here says "the full field list is in pm-parts.d.lua," it means: type a dot in your editor and read what autocomplete offers. The docs explain the common edits and the forms. The stubs are the exhaustive field-by-field reference, and they update with the API.
Keeping the stubs current
The stubs ship bundled with the extension, and they are updated when the extension updates. To pull the very latest stubs without waiting for an extension release, run PatchManager Lua: Update Stubs from Remote. To go back to the bundled set, run Reset to Bundled Stubs.
With the editor set up, move on to your first patch.