2014-12-11 11:56:37 +03:00
|
|
|
|
---
|
2018-09-14 17:00:44 +03:00
|
|
|
|
title: Getting Started
|
2014-12-11 11:56:37 +03:00
|
|
|
|
layout: default
|
2018-07-15 21:36:35 +03:00
|
|
|
|
root: ../..
|
2018-07-15 17:28:10 +03:00
|
|
|
|
idx: 1.1
|
2018-09-20 21:12:18 +03:00
|
|
|
|
description: Learn how to make a mod folder, including init.lua, mod.conf and more.
|
2018-09-14 17:00:44 +03:00
|
|
|
|
redirect_from:
|
|
|
|
|
- /en/chapters/folders.html
|
|
|
|
|
- /en/basics/folders.html
|
2014-12-11 11:56:37 +03:00
|
|
|
|
---
|
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
|
## Introduction
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
Understanding the basic structure of a mod's folder
|
|
|
|
|
is an essential skill when creating mods.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-20 21:12:18 +03:00
|
|
|
|
* [What are Games and Mods?](#what-are-games-and-mods)
|
2018-09-15 19:04:19 +03:00
|
|
|
|
* [Mod Directory](#mod-directory)
|
2017-09-03 03:48:06 +03:00
|
|
|
|
* [Dependencies](#dependencies)
|
|
|
|
|
* [Mod Packs](#mod-packs)
|
|
|
|
|
* [Example](#example)
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-20 21:12:18 +03:00
|
|
|
|
|
|
|
|
|
## What are Games and Mods?
|
|
|
|
|
|
|
|
|
|
The power of Minetest is the ability to easily create games without the need
|
|
|
|
|
to write your own voxel graphics and algorithms or fancy networking.
|
|
|
|
|
|
|
|
|
|
In Minetest, a Game is a collection of modules which work together to provide the
|
|
|
|
|
content and behaviour of your game.
|
|
|
|
|
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
|
|
|
|
|
infeasible.
|
|
|
|
|
|
|
|
|
|
It's also possible to distribute mods outside of a game, in which case they
|
|
|
|
|
are also *mods* in the more traditional sense - modifications.
|
|
|
|
|
Both the mods contained in a Game and third-party mods use the exact same API,
|
|
|
|
|
which makes things easier.
|
|
|
|
|
This book will go over the main parts of the Minetest API,
|
|
|
|
|
and is applicable for both game developers and modders.
|
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
## Mod Directory
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
Each mod has its own directory where all its Lua code, textures, models, and
|
|
|
|
|
sounds are placed. These directories need to be placed in a mod location such as
|
2017-09-03 03:48:06 +03:00
|
|
|
|
minetest/mods.
|
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
![Find the mod's directory]({{ page.root }}/static/folder_modfolder.jpg)
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
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
|
|
|
|
|
describe what the mod does, and the directory which contains the components of a mod
|
2017-09-03 03:48:06 +03:00
|
|
|
|
needs to be given the same name as the mod name.
|
2018-09-14 17:00:44 +03:00
|
|
|
|
To find out if a mod name is available, try searching for it on
|
|
|
|
|
[content.minetest.net](https://content.minetest.net).
|
2014-12-18 21:57:13 +03:00
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
mymod
|
2018-09-24 19:16:00 +03:00
|
|
|
|
├── init.lua (required) - Runs when the game loads.
|
|
|
|
|
├── mod.conf (recommended) - Contains description and dependencies.
|
2018-09-15 19:04:19 +03:00
|
|
|
|
├── textures (optional)
|
|
|
|
|
│ └── ... any textures or images
|
|
|
|
|
├── sounds (optional)
|
|
|
|
|
│ └── ... any sounds
|
|
|
|
|
└── ... any other files or directories
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
Only the init.lua file is actually required in a mod for it to run on game load;
|
|
|
|
|
however, mod.conf is recommended and other components may be needed
|
|
|
|
|
to perform a mod's functionality.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
|
## Dependencies
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
A dependency is another mod which the mod requires to be loaded before itself.
|
|
|
|
|
The mod may require the other's mods code, items, or other resources to be available.
|
|
|
|
|
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
|
|
|
|
|
fail to load if the required mod isn't available.
|
|
|
|
|
An optional dependency is useful if you want to optionally support another mod if the
|
|
|
|
|
user wishes to use it.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
### mod.conf
|
|
|
|
|
|
|
|
|
|
Dependencies should be listed in mod.conf.
|
|
|
|
|
The file is used for mod metadata such as the mod's name, description, and other information.
|
|
|
|
|
|
|
|
|
|
name = mymod
|
|
|
|
|
description = Adds foo, bar, and bo
|
|
|
|
|
depends = modone, modtwo
|
|
|
|
|
optional_depends = modthree
|
|
|
|
|
|
|
|
|
|
### depends.txt
|
|
|
|
|
|
|
|
|
|
For compatibility with 0.4.x versions of Minetest, you'll need to also provide
|
|
|
|
|
a depends.txt file:
|
2014-12-31 19:51:24 +03:00
|
|
|
|
|
2017-08-26 21:01:51 +03:00
|
|
|
|
modone
|
|
|
|
|
modtwo
|
|
|
|
|
modthree?
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
Each modname is on its own line.
|
2014-12-12 19:52:20 +03:00
|
|
|
|
Mod names with a question mark following them are optional dependencies.
|
2017-09-03 03:48:06 +03:00
|
|
|
|
If an optional dependency is installed, it is loaded before the mod;
|
|
|
|
|
however, if the dependency is not installed, the mod still loads.
|
2015-11-08 18:57:40 +03:00
|
|
|
|
This is in contrast to normal dependencies which will cause the current
|
2015-02-24 12:27:49 +03:00
|
|
|
|
mod not to work if the dependency is not installed.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
|
## Mod Packs
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
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
|
|
|
|
|
a player but don't want to make them download each one individually.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
modpack1
|
2018-09-24 19:16:00 +03:00
|
|
|
|
├── modpack.lua (required) - signals that this is a mod pack
|
2018-09-15 19:04:19 +03:00
|
|
|
|
├── mod1
|
|
|
|
|
│ └── ... mod files
|
|
|
|
|
└── mymod (optional)
|
|
|
|
|
└── ... mod files
|
|
|
|
|
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
## Example
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
Are you confused? Don't worry, here is an example which puts all of this together:
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
|
|
|
|
### Mod Folder
|
2018-09-15 19:04:19 +03:00
|
|
|
|
mymod
|
|
|
|
|
├── textures
|
|
|
|
|
│ └── mymod_node.png files
|
|
|
|
|
├── depends.txt
|
|
|
|
|
├── init.lua
|
|
|
|
|
└── mod.conf
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
|
|
|
|
### depends.txt
|
2017-08-26 21:01:51 +03:00
|
|
|
|
default
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
|
|
|
|
### init.lua
|
2018-09-19 14:04:51 +03:00
|
|
|
|
```lua
|
2014-12-11 22:49:41 +03:00
|
|
|
|
print("This file will be run at load time!")
|
|
|
|
|
|
2015-02-19 17:55:37 +03:00
|
|
|
|
minetest.register_node("mymod:node", {
|
2017-08-26 21:01:51 +03:00
|
|
|
|
description = "This is a node",
|
|
|
|
|
tiles = {
|
|
|
|
|
"mymod_node.png",
|
|
|
|
|
"mymod_node.png",
|
|
|
|
|
"mymod_node.png",
|
|
|
|
|
"mymod_node.png",
|
|
|
|
|
"mymod_node.png",
|
|
|
|
|
"mymod_node.png"
|
|
|
|
|
},
|
|
|
|
|
groups = {cracky = 1}
|
2014-12-11 22:49:41 +03:00
|
|
|
|
})
|
2018-09-19 14:04:51 +03:00
|
|
|
|
```
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
### mod.conf
|
|
|
|
|
name = mymod
|
|
|
|
|
descriptions = Adds a node
|
|
|
|
|
depends = default
|
|
|
|
|
|
|
|
|
|
This mod has the name "mymod". It has three text files: init.lua, mod.conf,
|
|
|
|
|
and depends.txt.\\
|
|
|
|
|
The script prints a message and then registers a node –
|
|
|
|
|
which will be explained in the next chapter.\\
|
|
|
|
|
There's a single dependency, the
|
|
|
|
|
[default mod](https://content.minetest.net/metapackages/default/) which is
|
|
|
|
|
usually found in Minetest Game.\\
|
2015-02-24 12:30:05 +03:00
|
|
|
|
There is also a texture in textures/ for the node.
|
2018-09-14 17:00:44 +03:00
|
|
|
|
|
|
|
|
|
Please note that a *game* is not a modpack.
|
|
|
|
|
Games have their own organisational structure which will be explained in the
|
|
|
|
|
Games chapter.
|