Loading the heightmap from your mods folder - BFrizzleFoShizzle/RE_Kenshi GitHub Wiki

Intro

Kenshi's heightmap file fullmap.tif loads from a hard-coded path in Kenshi's data directory, and cannot normally be modded without overwriting this file.
You can use RE_Kenshi to rebind the path that Kenshi uses to load this file, allowing it to be loaded from your mod's directory without overwriting the original vanilla file.
This tutorial walks through the process of doing so, and requires no prior experience with RE_Kenshi modding.

Installing RE_Kenshi

File rebinding requires v0.2.2+ of RE_Kenshi. You can download RE_Kenshi from the Nexus page or GitHub releases. To install, extract the archive anywhere, run the installer, and follow it's instructions.
If the mod has installed correctly, the version text in Kenshi's main menu should read:
RE_Kenshi vx.x.x - Kenshi 1.0.x - x64 (Newland)

Finding file paths

In order for a mod to rebind a file path with RE_Kenshi, you need the EXACT file path Kenshi uses when opening the file. Kenshi doesn't use a consistent format for it's file paths, so attempting to guess a file path will often result in your file rebind not working. In order to solve this issue, RE_Kenshi has a system for logging file I/O operations, giving you exact file paths.
In RE_Kenshi's in-game menu, enable file I/O logging:

images/log_file_io.png

After enabling file I/O logging, it is generally a good idea to close and reopen the game.
Close + reopen the game, then load a save game or start a new game. This will cause the game to open the heightmap file, which will be logged. Once in-game, close Kenshi and open the file FileIOLog.txt in the root of Kenshi's install directory.

images/FileIOLog_folder.png

Hit ctrl+F and search for fullmap.tif

images/FileIOLog_fullmap.png

As you can see, the path Kenshi uses for loading the heightmap is data\newland/land\fullmap.tif
To reiterate, the path you use in your rebind config must EXACTLY MATCH this. For example, you cannot replace forward-slashes with back-slashes or vice versa.

Creating the mod

Open the FCS and create a new mod.

images/fcs_heightmap_mod.png

RE_Kenshi requires a mod to have a .mod file in order to detect it. In our case, since we are only using the mod to change the heightmap, this is effectively a dummy file. You can now close the FCS.

Create a file named RE_Kenshi.json in the root of the new mod's directory.

images/RE_Kenshi_json_folder.png

Open the file and paste the following in:

{
	"FileRebinds" : {
		"data\\newland/land\\fullmap.tif" : "$(modroot \"Heightmap mod\")/fullmap.tif"
	}
}

RE_Kenshi uses JSON for mod overrides. The paths used in the JSON file must be JSON-escaped (there are online tools for doing this).
When you JSON-escape the heightmap path data\newland/land\fullmap.tif you get data\\newland/land\\fullmap.tif which is the path you must use in this file.
File paths used in rebinds are relative to the root of your Kenshi install directory.
The modroot command $(modroot \"Heightmap mod\") will be replaced by the path to the root of the mod when RE_Kenshi parses this file. You could replace this with "./mods/Heightmap mod/fullmap.tif" if you wanted.
The modroot command is particularly useful for Steam mods as Steam will install your mod to a folder named with the Steam ID number of your mod. Using modroot means you don't have to worry about the exact name or path of this folder.

Copy the file fullmap.tif from Kenshi's data directory to the root of your mod.

images/fullmap_folder.png

You can now edit the file to your hearts content. Enable your mod through Kenshi's regular mod menu.
Final note: Users of your mod will also need to install RE_Kenshi v0.2.2+ to get the file rebinds working on their system. Once a user has installed RE_Kenshi, the installation steps for your mod are the same as for normal mods, e.g. copy the mod to Kenshi's mod directory (or install normally via steam) and enable the mod using Kenshi's mod menu.

More info:
Finding file paths for rebinding
Using RE_Kenshi to mod hard coded file paths