创建模组:修订间差异

本页面讲述的内容长期有效
(RemixMe移动页面Creating a mod创建模组
(翻译)
第1行: 第1行:
{{version|Timeless}}
{{version|Timeless}}
{{需要翻译}}
本教程详细说明了创建基本mod所需的步骤。


This tutorial explains in details the steps required to create a basic mod.
同时你也可以复制和修改现有的模组来达成相同效果。不过要注意的是通过[[Steam创意工坊]]安装的模组,它们的包装方式不太相同。


Note that another approach is to copy/paste and modify an existing mod (though not a mod installed via [[Steam Workshop]] since these are packaged differently).


It is assumed that the OS is Windows, but this could apply to MacOS or Linux with few changes.
此处基于的操作系统(作业系统)是Windows,但是理论上在MacOS和Linux不会有太大不同。


== Prerequisites ==
== 先决条件==


* Install a good text editor (like [http://notepad-plus-plus.org Notepad++]), since default Notepad on Windows screws the file encoding.
* 安装一个好的文件编辑器(像是[http://notepad-plus-plus.org Notepad++] ),因为因为Windows上预设的记事本会改变文件编码。


== Steps ==
== 步骤==


=== Create the CK2 mod directory ===
=== 创建CK2的模组目录===


There are 2 different directories involved:
这里涉及到两个不同的目录:


* The CK2 install directory: it contains the base game files, which should not be modified directly and considered 'read-only' (modifications will be lost when Steam is updating). It can be found via Steam: find CK2 in your games library, right click on the name and select ''properties'' in the menu. Choose the ''local files'' tab and then press ''browse local files''.
*CK2 的安装目录:它包含游戏的基本文件,最好不要尝试修改,并考虑' 唯读模式' (任何的修改会在Steam更新时丢失)
**这个目录可以通过Steam找到:在游戏库中找到CK2,右键单击名称,然后在菜单中选择“属性”。 选择“本地文件”选项卡,然后按“浏览本地文件”。


* The CK2 user files: it contains the user data (saves, game preferences, logs and mods). The path is <code>~/My Documents/Paradox Interactive/Crusader Kings II/</code>. <code>~</code> is the home directory, depending on your configuration and Windows version, this could look like: <code>C:\Users\<YourUser>\Documents\Paradox Interactive\Crusader Kings II</code>
*CK2 的使用者文件: 它包含使用者的数据(存档、游戏设定、日志和模组。
**路径是<code>~/My Documents/Paradox Interactive/Crusader Kings II/</code>
**<code>~</code> 是主目录,根据你的配置和Windows版本,它可能长得像:<code>C:\Users\<YourUser>\Documents\Paradox Interactive\Crusader Kings II</code>


''Tip'': you may create shortcuts to these directories on your desktop.
''' 小提示''':你可以在桌面上创建这些目录的快捷方式。


'''Step 1''': Create a mod folder <code>~/My Documents/Paradox Interactive/Crusader Kings II/mod/</code>, if it doesn't exist.
''' 第一步''' :如果不存在mod资料夹,就自行创建一个。<code>~/My Documents/Paradox Interactive/Crusader Kings II/mod/</code>


''Note'': there is also a legacy <code>common\Crusader Kings II\mod\</code> folder in the CK2 install directory, but it must not be used to store mods.
''' 注意''':在游戏文件的目录也存在一个同名资料夹<code>common\Crusader Kings II\mod\</code> 但是存在里头的模组不会被读取。


=== Create the .mod file ===
=== 创建.mod 文件 ===


The .mod format here is just a plain text file, saved with .mod file extension instead of the .txt extension.
.mod 格式只是个纯文本的文件,使用.mod 文件扩展名而不是.txt 扩展名保存。


''Tip'': most CK2 files use .txt extension, but there is also .csv (localization), .gfx (graphics), .sfx (sounds), .gui (interface), .lua (global variables) and .info (documentation).
''' 小提示''':most CK2 files use .txt extension, but there is also .csv (localization), .gfx (graphics), .sfx (sounds), .gui (interface), .lua (global variables) and .info (documentation).


'''Step 2''': Create an empty file named "mymod.mod" in the CK2 mod folder (<code>~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod.mod</code>).
''' 第二步''' :Create an empty file named "mymod.mod" in the CK2 mod folder (<code>~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod.mod</code>).


''Note'': make sure the file extension is .mod (and not .mod.txt) - disable "Hide Known Extensions" option of Windows explorer.
''' 注意''':make sure the file extension is .mod (and not .mod.txt) - disable "Hide Known Extensions" option of Windows explorer.


'''Step 3''': Open the file with your editor and add:
'''Step 3''': Open the file with your editor and add:
第58行: 第62行:
''Note'': folder and file names are case sensitive on OS other than Windows, so a best practice is to use only lower-case.
''Note'': folder and file names are case sensitive on OS other than Windows, so a best practice is to use only lower-case.


=== Making a game modification ===
=== 进行游戏修改===


[[File:Creating_mod_localisation.jpg|300px|thumb|right|Creation of 00_mymod.csv file]]
[[File:Creating_mod_localisation.jpg|300px|thumb|right|Creation of 00_mymod.csv file]]
第85行: 第89行:
That's it !
That's it !


=== Testing the mod ===
=== 测试模组===


[[File:Creating_mod_result.jpg|600px|thumb|right|The modded era selection screen]]
[[File:Creating_mod_result.jpg|600px|thumb|right|The modded era selection screen]]
第103行: 第107行:
''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.
''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.


== What's next ? ==
== 下一步?==


* Mod other [[Modding#Game structure| game files]]. Take it slowly, with small challenge, one problem at a time !
* Mod other [[Modding#Game structure| game files]]. Take it slowly, with small challenge, one problem at a time !
第110行: 第114行:
* Zip the mymod.mod and mymod folder together into a mymod.zip and upload the mod on the forum
* Zip the mymod.mod and mymod folder together into a mymod.zip and upload the mod on the forum


== External links ==
== 外部连结==


* [[forum:1001172|Guide: Your first mod]] - to add an event option.
* [[forum:1001172|Guide: Your first mod]] - 添加事件的选项。
 
== 参考==
==References==


<references />
<references />


[[Category:Modding guides]]
[[Category:Modding guides]]

2020年1月31日 (五) 07:13的版本

本教程详细说明了创建基本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扩展名保存。

小提示:most CK2 files use .txt extension, but there is also .csv (localization), .gfx (graphics), .sfx (sounds), .gui (interface), .lua (global variables) and .info (documentation).

第二步:Create an empty file named "mymod.mod" in the CK2 mod folder (~/My Documents/Paradox Interactive/Crusader Kings II/mod/mymod.mod).

注意:make sure the file extension is .mod (and not .mod.txt) - disable "Hide Known Extensions" option of Windows explorer.

Step 3: Open the file with your editor and add:

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

Notes:

  • Don't forget the quotes, it is mandatory in case there is a space.
  • Save the file with ANSI (Windows-1252) encoding. This is true for all CK2 files: never use UTF-8 encoding (with or without 'BOM') !

Tip: the path is relative to CK2 user directory, hence the "mod/" prefix.

Create the mod data folder

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

Tip: best practice is to use same name for path folder than the mod file name, so that they are next to each other when browsing the CK2 mod folder.

Note: folder and file names are case sensitive on OS other than Windows, so a best practice is to use only lower-case.

进行游戏修改

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.

下一步?

外部连结

参考