Getting Started: Improve chapter
This commit is contained in:
parent
2ed367aa28
commit
63792fe2ac
@ -11,8 +11,8 @@ redirect_from:
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Understanding the basic structure of a mod's folder
|
Understanding the basic structure of a mod's folder is an essential skill when
|
||||||
is an essential skill when creating mods.
|
creating mods.
|
||||||
|
|
||||||
* [What are Games and Mods?](#what-are-games-and-mods)
|
* [What are Games and Mods?](#what-are-games-and-mods)
|
||||||
* [Mod Directory](#mod-directory)
|
* [Mod Directory](#mod-directory)
|
||||||
@ -23,25 +23,28 @@ is an essential skill when creating mods.
|
|||||||
|
|
||||||
## What are Games and Mods?
|
## What are Games and Mods?
|
||||||
|
|
||||||
The power of Minetest is the ability to easily create games without the need
|
The power of Minetest is the ability to easily develop games without the need
|
||||||
to write your own voxel graphics and algorithms or fancy networking.
|
to create your own voxel graphics, voxel algorithms or fancy networking code.
|
||||||
|
|
||||||
In Minetest, a Game is a collection of modules which work together to provide the
|
In Minetest, a game is a collection of modules which work together to provide the
|
||||||
content and behaviour of your game.
|
content and behaviour of a game.
|
||||||
A module, commonly known as a mod, is a collection of scripts and resources.
|
A module, commonly known as a mod, is a collection of scripts and resources.
|
||||||
It's possible to make a Game using only one mod, but this is rarely done and makes things
|
It's possible to make a game using only one mod, but this is rarely done because it
|
||||||
infeasible.
|
reduces the ease by which parts of the game can be adjusted and replaced
|
||||||
|
independently of others.
|
||||||
|
|
||||||
It's also possible to distribute mods outside of a game, in which case they
|
It's also possible to distribute mods outside of a game, in which case they
|
||||||
are also *mods* in the more traditional sense - modifications.
|
are also *mods* in the more traditional sense - modifications. These mods adjust
|
||||||
Both the mods contained in a Game and third-party mods use the exact same API,
|
or extend the features of a game.
|
||||||
which makes things easier.
|
|
||||||
This book will go over the main parts of the Minetest API,
|
Both the mods contained in a game and third-party mods use the same API.
|
||||||
|
|
||||||
|
This book will cover the main parts of the Minetest API,
|
||||||
and is applicable for both game developers and modders.
|
and is applicable for both game developers and modders.
|
||||||
|
|
||||||
## Mod Directory
|
## Mod Directory
|
||||||
|
|
||||||
Each mod has its own directory where all its Lua code, textures, models, and
|
Each mod has its own directory where its Lua code, textures, models, and
|
||||||
sounds are placed. These directories need to be placed in a mod location such as
|
sounds are placed. These directories need to be placed in a mod location such as
|
||||||
minetest/mods.
|
minetest/mods.
|
||||||
|
|
||||||
@ -50,7 +53,7 @@ minetest/mods.
|
|||||||
A "mod name" is used to refer to a mod. Each mod should have a unique name.
|
A "mod name" is used to refer to a mod. Each mod should have a unique name.
|
||||||
Mod names can include letters, numbers, and underscores. A good name should
|
Mod names can include letters, numbers, and underscores. A good name should
|
||||||
describe what the mod does, and the directory which contains the components of a mod
|
describe what the mod does, and the directory which contains the components of a mod
|
||||||
needs to be given the same name as the mod name.
|
must have the same name as the mod name.
|
||||||
To find out if a mod name is available, try searching for it on
|
To find out if a mod name is available, try searching for it on
|
||||||
[content.minetest.net](https://content.minetest.net).
|
[content.minetest.net](https://content.minetest.net).
|
||||||
|
|
||||||
@ -63,41 +66,48 @@ To find out if a mod name is available, try searching for it on
|
|||||||
│ └── ... any sounds
|
│ └── ... any sounds
|
||||||
└── ... any other files or directories
|
└── ... any other files or directories
|
||||||
|
|
||||||
Only the init.lua file is actually required in a mod for it to run on game load;
|
Only the init.lua file is required in a mod for it to run on game load;
|
||||||
however, mod.conf is recommended and other components may be needed
|
however, mod.conf is recommended and other components may be needed
|
||||||
to perform a mod's functionality.
|
depending on the mod's functionality.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
A dependency is another mod which the mod requires to be loaded before itself.
|
A dependency occurs when a mod requires another mod to be loaded before itself.
|
||||||
The mod may require the other's mods code, items, or other resources to be available.
|
One mod may require another mod's code, items, or other resources to be available
|
||||||
|
for it to use.
|
||||||
|
|
||||||
There are two types of dependencies: hard and optional dependencies.
|
There are two types of dependencies: hard and optional dependencies.
|
||||||
Both require the mod to be loaded first, but a hard dependency will cause the mod to
|
Both require the mod to be loaded first. If the mod being depended on isn't
|
||||||
fail to load if the required mod isn't available.
|
available, a hard dependency will cause the mod to fail to load, while an optional
|
||||||
An optional dependency is useful if you want to optionally support another mod if the
|
dependency might lead to fewer features being enabled.
|
||||||
user wishes to use it.
|
|
||||||
|
An optional dependency is useful if you want to optionally support another mod; it can
|
||||||
|
enable extra content if the user wishes to use both the mods at the same time.
|
||||||
|
|
||||||
|
Dependencies should be listed in mod.conf.
|
||||||
|
|
||||||
### mod.conf
|
### mod.conf
|
||||||
|
|
||||||
Dependencies should be listed in mod.conf.
|
This file is used for mod metadata including the mod's name, description, and other
|
||||||
The file is used for mod metadata such as the mod's name, description, and other information.
|
information. For example:
|
||||||
|
|
||||||
name = mymod
|
name = mymod
|
||||||
description = Adds foo, bar, and bo
|
description = Adds foo, bar, and bo.
|
||||||
depends = modone, modtwo
|
depends = modone, modtwo
|
||||||
optional_depends = modthree
|
optional_depends = modthree
|
||||||
|
|
||||||
### depends.txt
|
### depends.txt
|
||||||
|
|
||||||
For compatibility with 0.4.x versions of Minetest, you'll need to also provide
|
For compatibility with 0.4.x versions of Minetest, instead of only specifying
|
||||||
a depends.txt file:
|
dependencies in mod.conf, you need to provide a depends.txt file in which
|
||||||
|
you list all dependencies:
|
||||||
|
|
||||||
modone
|
modone
|
||||||
modtwo
|
modtwo
|
||||||
modthree?
|
modthree?
|
||||||
|
|
||||||
Each modname is on its own line.
|
Each mod name is on its own line, and mod names with a question mark
|
||||||
Mod names with a question mark following them are optional dependencies.
|
following them are optional dependencies.
|
||||||
If an optional dependency is installed, it is loaded before the mod;
|
If an optional dependency is installed, it is loaded before the mod;
|
||||||
however, if the dependency is not installed, the mod still loads.
|
however, if the dependency is not installed, the mod still loads.
|
||||||
This is in contrast to normal dependencies which will cause the current
|
This is in contrast to normal dependencies which will cause the current
|
||||||
@ -107,7 +117,7 @@ mod not to work if the dependency is not installed.
|
|||||||
|
|
||||||
Mods can be grouped into mod packs which allow multiple mods to be packaged
|
Mods can be grouped into mod packs which allow multiple mods to be packaged
|
||||||
and moved together. They are useful if you want to supply multiple mods to
|
and moved together. They are useful if you want to supply multiple mods to
|
||||||
a player but don't want to make them download each one individually.
|
a player, but don't want to make them download each one individually.
|
||||||
|
|
||||||
modpack1
|
modpack1
|
||||||
├── modpack.lua (required) - signals that this is a mod pack
|
├── modpack.lua (required) - signals that this is a mod pack
|
||||||
@ -116,10 +126,13 @@ a player but don't want to make them download each one individually.
|
|||||||
└── mymod (optional)
|
└── mymod (optional)
|
||||||
└── ... mod files
|
└── ... mod files
|
||||||
|
|
||||||
|
Please note that a modpack is not a *game*.
|
||||||
|
Games have their own organisational structure which will be explained in the
|
||||||
|
Games chapter.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Are you confused? Don't worry, here is an example which puts all of this together:
|
Here is an example which puts all of this together:
|
||||||
|
|
||||||
### Mod Folder
|
### Mod Folder
|
||||||
mymod
|
mymod
|
||||||
@ -138,14 +151,7 @@ print("This file will be run at load time!")
|
|||||||
|
|
||||||
minetest.register_node("mymod:node", {
|
minetest.register_node("mymod:node", {
|
||||||
description = "This is a node",
|
description = "This is a node",
|
||||||
tiles = {
|
tiles = {"mymod_node.png"},
|
||||||
"mymod_node.png",
|
|
||||||
"mymod_node.png",
|
|
||||||
"mymod_node.png",
|
|
||||||
"mymod_node.png",
|
|
||||||
"mymod_node.png",
|
|
||||||
"mymod_node.png"
|
|
||||||
},
|
|
||||||
groups = {cracky = 1}
|
groups = {cracky = 1}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@ -160,10 +166,6 @@ and depends.txt.\\
|
|||||||
The script prints a message and then registers a node –
|
The script prints a message and then registers a node –
|
||||||
which will be explained in the next chapter.\\
|
which will be explained in the next chapter.\\
|
||||||
There's a single dependency, the
|
There's a single dependency, the
|
||||||
[default mod](https://content.minetest.net/metapackages/default/) which is
|
[default mod](https://content.minetest.net/metapackages/default/), which is
|
||||||
usually found in Minetest Game.\\
|
usually found in Minetest Game.\\
|
||||||
There is also a texture in textures/ for the node.
|
There is also a texture in textures/ for the node.
|
||||||
|
|
||||||
Please note that a *game* is not a modpack.
|
|
||||||
Games have their own organisational structure which will be explained in the
|
|
||||||
Games chapter.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user