-
Notifications
You must be signed in to change notification settings - Fork 4
ModTutorialHome
In this tutorial, we will use a simple mod as an example to introduce the basic usage of NeoModLoader.
First, you need to read How To Ask Questions The Smart Way
Then, you need to install a text editor, such as Visual Studio Code, Visual Studio or Rider.
Of course, you can also use Notepad.
And, the most basic C# language knowledge (don't even unable to understand the access permissions).
And the most important thing is to install WorldBox and NeoModLoader.
Use this repository as a template(use as template), clone it to the Mods folder.
If you don't know how to use git, please refer to this tutorial.
If you haven't done anything wrong, you should see such a file structure:
├───ModTemplate
│ ├───Locales
│ │ └───en.json
│ │ └───cz.json
│ ├───Properties
│ │ └───AssemblyInfo.cs
│ ├───.gitignore
│ ├───ModClass.cs
│ ├───ModTemplate.csproj
│ ├───ModTemplate.sln
│ ├───default_config.json
│ ├───icon.png
│ ├───mod.json
Among them, mod.json
is used to describe the information of the mod, default_config.json
is used to provide the default settings of the mod (which will be introduced later), and icon.png
is the icon file of the mod.
In the Locales
folder, you can see en.json
and cz.json
, these two files are used to provide the localization information of the mod, you can add your own language in them.
ModClass.cs
is the main class of the mod, which has implemented BasicMod
, you can add your own code in it.
mod.json
describes the information of the mod in JSON format, you can use any text editor to edit it.
{
"name": "CHANGEME",
"author": "CHANGEME",
"version": "1.0.0",
"description": "This is a template for a mod",
"RepoUrl": "https://github.com/author/name",
"iconPath": "icon.png"
}
The name
field is the name of the mod, the author
field is the author of the mod, the version
field is the version of the mod, the description
field is the description of the mod, the RepoUrl
field is the URL of the repository of the mod, and the iconPath
field is the path of the icon file of the mod.
Here is the most basic configuration, more configuration items refer to the documentation.
You need to replace CHANGEME
with your own information.
The following is an example of a complete mod.json
:
{
"name": "ModTemplate",
"author": "WorldBoxOpenMods",
"version": "1.0.0",
"description": "This is a template for a mod",
"RepoUrl": "https://github.com/WorldBoxOpenMods/ModTemplate",
"iconPath": "icon.png"
}
Modify the namespace "CHANGEME" in ModClass.cs
to your own namespace.
Now, you have created a mod, you can run it in WorldBox. And you can see the following log in the console:
[NML][ModTemplate]: OnLoad
[NML][ModTemplate]: Hello World!
[NML][ModTemplate]: Loaded
In addition, in the mod management interface provided by ModLoader, you can also see your mod.
The following tutorials are just an explanation of some of the original functions, and an introduction to some of the encapsulated functions. You can read recommended content selectively.
Most example codes are in ModExample
No English version yet, please refer to the Chinese version.
Goto Chinese Version
If you want to help translate, please contact me [email protected].
No English version yet, please refer to the Chinese version.
Goto Chinese Version
If you want to help translate, please contact me [email protected].