Skip to content

Using RE_Kenshi to mod hard coded file paths

Bryden Frizzell edited this page Dec 21, 2021 · 2 revisions

This page describes RE_Kenshi's file rebind API.

With RE_Kenshi, modders can change the load path for any files loaded by Kenshi, including those with hard-coded paths. This is done by adding a JSON-formatted file named RE_Kenshi.json to the root of your mod's directory. When your mod is loaded, this file is read by RE_Kenshi and applied to the game.

The RE_Kenshi.json file must contain a valid JSON object with a dictionary named "FileRebinds", which maps paths to be replaced to their replacement.
Example:

{
    "FileRebinds" : {
        "file/to/replace.png": "path/of/replacement.png",
        "file\\to/replace2.png": "paths\\must/be/json/string\\escaped.png",
        "file/to/replace3.png": "$(modroot \"Your mod name here\")/this_path_is_from_the_root_of_your_mod/replacement.png",
        "file/to/replace4.png": "if_you_put_a_comma_after_the_last_file_everything_breaks.png"
    }
}

Paths are relative to Kenshi's install directory. The modroot command will substitute in the path to the root of a loaded mod. This is potentially useful for Steam mods where the name/path of your mod folder is different to the name of the mod, using $(modroot \"Your mod name here\") will substitute the path to your mod without having to know the exact name of it's folder.
It's important to note that the keys of the FileRebinds dictionary must EXACTLY MATCH the path Kenshi uses when loading the file, including forward slashes vs back slashes. You can use RE_Kenshi to log loaded file paths.