Skip to content

Writing Your First Patch

Kakrain edited this page Jun 14, 2026 · 1 revision

Writing Your First Patch

This guide walks you through writing your first .patch file and successfully generating a patched mod using KenshiPatcher.

You will learn:

  • How to select records using a variable
  • How to apply a simple field change
  • How to run the patch and see the results.

Step 1 -> Create a Patch Mod

  1. Create a new mod using FCS, example HatPatch:

  1. In the same folder of your mod create a text file named:
HatPatch.patch

⚠ Both files must share the exact same filename
HatPatch.mod ↔ HatPatch.patch


Step 2 -> Add Patch Rules

Open HatPatch.patch in a text editor and write:

allraces:=(all)(A:RACE|true)
@Print(allraces)

What this does:

Text Meaning
allraces:= Store the results in a variable named allraces
(all) Search all active mods
A: Return all matching records
RACE: Look for race records
| true Accept every race found
@Print(allraces) Print the selected records to the log

Don't worry if the syntax looks unfamiliar.

For now, just run the patch and inspect the results. We'll explain selectors, conditions, and variables later.


Step 3 -> Run KenshiPatcher

  1. Activate your mod using the Kenshi Launcher and press:
Save Config
  1. Launch:
KenshiPatcher.exe
  1. Select the mod you created:

HatPatch.mod

  1. Click:
Patch It!
  1. The Log will show all the records selected:

The log confirms that KenshiPatcher found the records we asked for.

KenshiPatcher will generate a new version of the mod:

  • Original blank mod saved as: HatPatch.unpatched
  • Updated version saved as: HatPatch.mod

Safe to rerun anytime!


Step 4 -> Write some values

Open HatPatch.patch again and replace it by:

allraces:=(all)(A:RACE|!isRemoved())
allraces->SetField("no hats",false)

All Races are now races which are not removed.

This sets the field "no hats" to false, meaning all races will be able to wear hats.

Rerun this Patch with KenshiPatcher.

Open this mod with FCS, you will be able to see the generated changes

At the start it will tell you some mods are not there, don't worry, it is because FCS can't see workshop mods.


Check in Game

  1. Open the Kenshi Launcher
  2. Ensure HatPatch is enabled
  3. Start the game
  4. Check any race that normally cannot wear hats

If they can now wear hats -> success!


Troubleshooting

If you see no changes, check the HatPatch log

Clone this wiki locally