LuaPatch cheat sheet
Every method in the patch chain, grouped by what it does. All of them return the patch, so they chain. For the full explanation of any group, follow the link.
Starting a patch
These come from a module and return a patch to chain on. See Targeting assets.
Call | What it does |
|---|---|
| Patch any asset under |
| Patch parts. |
| Patch celestial bodies. |
| Patch resources and recipes. |
| Patch a science asset kind. |
| Patch missions. |
| Patch campaign packs. |
| Patch one galaxy definition. |
| Patch with an explicitly named converter. |
Copying
These also start a patch, and copy each matched asset before running the chained :Do callback on the copy. See Copying an existing asset.
Call | What it does |
|---|---|
| Copy any asset under |
| Copy parts. |
| Copy a galaxy definition. |
| Copy an atmosphere or cloud override. |
| Copy a science asset kind. |
| Copy with an explicitly named converter. |
source takes * and ? wildcards, and newName takes {name} for the source's name. Each also takes the callback as an optional last argument, as shorthand for :Do. A copy keeps the internal ids of its source (partName, bodyName). Give the copy a new id in the callback.
The change
See The Do callback.
Call | What it does |
|---|---|
| The callback that edits the asset. Return |
Targeting
See Targeting assets.
Call | What it does |
|---|---|
| Run only against these asset ids. Repeatable. |
| Do not run against these asset ids. |
Gates
See Gates.
Call | What it does |
|---|---|
| Skip unless the predicate (or constant boolean) passes. |
| Skip unless the asset exposes |
| Skip if the asset exposes |
Features
See Features. An id without a mod prefix is a feature of your mod. Each patch also needs the default feature of your mod.
Call | What it does |
|---|---|
| Run only in feature sets that have all of the listed features on. Also available on created assets and |
| Run only in feature sets that have none of the listed features on. |
| Add the feature to each patch, created asset, prefab patch, run callback and config entry that the function registers. |
| Declare a feature, with |
| Run before the patch run of each feature set. Accepts |
| Run after the patch run of each feature set. |
Pass and bucket
See The patch lifecycle.
Call | What it does |
|---|---|
| Run in the early pass. |
| Run in the late pass. |
| Run in the first bucket of its pass. |
| Run in the last bucket of its pass. |
Default (none of these) is the Default pass, Default bucket.
Dependencies
See Dependencies and ordering. These take mod ids or patch ids.
Call | What it does |
|---|---|
| Run only if these mods are installed and on in the feature set. |
| Skip if one of these mods is installed and on in the feature set. |
| Run only if these patches also run. |
| Skip if any of these patches runs. |
Ordering
Within the same bucket only.
Call | What it does |
|---|---|
| Run after every patch from these mods. |
| Run before every patch from these mods. |
| Run after these patches. |
| Run before these patches. |
JSON value methods
Available on the value inside a callback. See Working with JSON.
Call | What it does |
|---|---|
| Add to the end of an array. |
| Insert at a 1-indexed position. |
| Remove the element at a 1-indexed position. |
| Remove every element the predicate matches. |
| Empty an array. |
| Number of elements. |
| Whether an object has a key. |
| An object's property names. |
| Remove an object property. |
| Edit the value at |
J helpers
See Working with JSON.
Call | What it does |
|---|---|
| Force an integer into a new or non-integer JSON slot. |
| Make an empty JSON array. |
| Convert a Lua value to the JSON-backed form. |