Repository navigation
Language Reference
This page explains the full scripting language used by KenshiPatcher .patch files.
It is designed for mod creators, not typical users.
Patch rules are written using three primary statement types:
| Statement Type | Symbol | Purpose |
|---|---|---|
| Definition | := |
Select records into a variable |
| Extraction | <<< |
Split records into matching and remaining |
| Procedure |
-> / ~>
|
Modify records |
Additional syntax elements:
| Feature | Symbol |
|---|---|
| Lambda expressions | => |
| Global Functions |
@ prefix |
| Comments | ; |
; This is a comment
Everything after ; on the same line is ignored.
Definitions select records from mods into variables.
variable := (mod_selector)(mode:TYPE | condition)
| Selector | Meaning |
|---|---|
(all) |
Search in all loaded mods |
(mod1.mod) |
Search only in mod1.mod |
(mod1.mod,mod2.mod) |
Search only in these mods |
(*mod1.mod,mod2.mod) |
Search in all mods except these |
.mod extension is required.
| Mode | Meaning |
|---|---|
A |
Select all matching records |
E |
Select first matching record |
| Number | Select N records |
You must specify a valid Kenshi record type:
(e.g. RACE, ARMOUR, BUILDING, BIOME, etc)
Use FCS or KenshiUtilities to find the correct type name.
Conditions filter which records are selected.
Logical operators supported:
| Operator | Meaning |
|---|---|
! |
NOT |
&& |
AND |
|| |
OR |
== |
Equals |
!= |
Not equals |
< |
Less than |
> |
Greater than |
<= |
Less or equal than |
>= |
Greater or equal than |
| Operator | Meaning |
|---|---|
+ |
plus |
- |
minus |
* |
multiplication |
/ |
division |
% |
modulo |
Split records: left gets matching, right keeps remaining.
hairyraces <<< (allraces|hasAnyAsExtraData(hairs,"hair"))
After this:
-
hairyracesnow contains only matching elements -
allracesloses those entries permanently
Use when you want exclusive subsets.
A->SetText(x=>x + " you know? ")
Here, it modifies every text (text0, text1, text2,...etc) to append " you know? " at the end to every text
Additionally there are multiple kind of functions:
-
Getting Started
-
Cookbook
-
Patch Language
-
Variable Types
-
Miscellaneous
-
Support