创建模组

本页面讲述的内容长期有效

本教程详细说明了创建基本mod所需的步骤。

同时你也可以复制和修改现有的模组来达成相同效果。不过要注意的是通过Steam创意工坊安装的模组,它们的包装方式不太相同。


此处基于的操作系统(作业系统)是Windows,但是理论上在MacOS和Linux不会有太大不同。

先决条件

  • 安装一个好的文件编辑器(像是Notepad++),因为因为Windows上预设的记事本会改变文件编码。

步骤

创建CK2的模组目录

这里涉及到两个不同的目录:

  • CK2的安装目录:它包含游戏的基本文件,最好不要尝试修改,并考虑'唯读模式'(任何的修改会在Steam更新时丢失)
    • 这个目录可以通过Steam找到:在游戏库中找到CK2,右键单击名称,然后在菜单中选择“属性”。 选择“本地文件”选项卡,然后按“浏览本地文件”。
  • CK2的使用者文件:它包含使用者的数据(存档、游戏设定、日志和模组。
    • 路径是~/My Documents/Paradox Interactive/Crusader Kings II/
    • ~是主目录,根据你的配置和Windows版本,它可能长得像:C:\Users\<YourUser>\Documents\Paradox Interactive\Crusader Kings II

小提示:你可以在桌面上创建这些目录的快捷方式。

第一步:如果不存在mod资料夹,就自行创建一个。~/My Documents/Paradox Interactive/Crusader Kings II/mod/

注意:在游戏文件的目录也存在一个同名资料夹common\Crusader Kings II\mod\ 但是存在里头的模组不会被读取。

创建.mod文件

.mod格式只是个纯文本的文件,使用.mod文件扩展名而不是.txt扩展名保存。

小提示:大部分CK2 文件的扩展名是.txt, 但有时也会是.csv (国家名称和时间描述), .gfx (图像图片), .sfx (音效音乐), .gui (图形界面), .lua (全局变量) and .info (文档文件)。

第二步:创建一个文件名为“mymod.mod”的空文件,放到 CK2 mod 文件夹下(~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod.mod).

注意:情人你的文件扩展名是'.mod'(而不是‘.mode.txt') - 在Windows系统的文件管理器中禁用“隐藏已知扩展”的选项。

第三步: 用你的编辑器打开.mod文件,并在里面添加一下内容:

name = "My mod"
path = "mod/mymod"

注意:

  • 不要忘记引号,这是强制性的,以防有空格。
  • 用 ANSI(Windows-1252) 编码保存文件。这对所有 CK2 文件都适用:绝对不要使用 UTF-8 编码 (或者是没有'BOM'的UTF-8 编码)!

提示: path 设定的路径是相对于用户的 CK2 目录而言的,因此要加上“/mod”前缀。

创建 mod 的数据文件夹

第四步Step 4: 在 CK2 的 mod 目录下创建一个名为“mymod”的空文件夹 (~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod/).

提示: 路径文件夹最好与mod文件同名,以便在查看 CK2 mod 文件时,他们是排列在一起的。

注意: 文件夹和文件的名称大小写在 Windows 以外的操作系统上是敏感的我,所以名称最好只用小写字母。

进行游戏修改

Creation of 00_mymod.csv file

We need a little change that will be quickly visible in-game, to validate that the mod is working.

Let's do some basic localization modding and change the text "Choose Your Starting Era" on the lobby to "Choose Your Favourite Era" (the corresponding localisation key is PICK_YOUR_STARTING_ERA)

Step 5: Create an empty folder named "localisation" in the mod data folder (~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod/localisation/).

Notes:

  • A mod follows the same folder structure as the base game, and the two are merged when loading in memory.
  • Beware the folder has to be named "localisation" and not "localization" !

Step 6: Create an empty file named "00_mymod.csv" in that folder (~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod/localisation/00_mymod.csv).

Tip: the "00_" prefix is to ensure our localization is loaded first and overrides the vanilla one. Each folder has its own loading order/overriding behavior.

Step 7: Open the file with a text editor and copy the following lines to the file and save:

#CODE;ENGLISH;FRENCH;GERMAN;;SPANISH;;;;;;;;;x
PICK_YOUR_STARTING_ERA;Choose Your Favourite Era;;;;;;;;;;;;;x

That's it !

测试模组

The modded era selection screen

Step 8: Activate the mod "My mod" in the launcher (and don't activate any other mod) and start the game.

Troubleshooting: if the mod doesn't show up in the launcher, it probably means the .mod file is not in the correct folder or has the wrong extension (.txt instead of .mod).

Tip: notice that the in-game checksum has not changed compared to the one from the launcher. This is because the localisation folder doesn't alter the checksum, as it's only a cosmetic change.

Step 9: Click on Start and verify that the title of the pop-up has changed.

Troubleshooting: if the change is not visible in game, or the game crashes, check for errors logged by the game at startup in error.log.

Step 10: Take some time to congratulate yourself, and go back for more modding !

Note: each time you modify something in the mod files, you need to stop and restart CK2 so that the change is taken into account.

下一步?

外部连结

参考