Repository navigation
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.
- Create a new mod using FCS, example HatPatch:
- 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
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.
- Activate your mod using the Kenshi Launcher and press:
Save Config
- Launch:
KenshiPatcher.exe
- Select the mod you created:
HatPatch.mod
- Click:
Patch It!
- 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!
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.
- Open the Kenshi Launcher
- Ensure HatPatch is enabled
- Start the game
- Check any race that normally cannot wear hats
If they can now wear hats -> success!
If you see no changes, check the HatPatch log
-
Getting Started
-
Cookbook
-
Patch Language
-
Variable Types
-
Miscellaneous
-
Support