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
|
|
|
|
---
|
|
|
|
|
|
2019-05-31 20:32:40 +03:00
|
|
|
|
## Introduction <!-- omit in toc -->
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
Understanding the basic structure of a mod's folder is an essential skill when
|
2022-07-31 19:20:24 +03:00
|
|
|
|
creating mods. In this chapter, you'll learn about how modding in Minetest works
|
|
|
|
|
and create your first mod.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2019-05-31 20:32:40 +03:00
|
|
|
|
- [What are Games and Mods?](#what-are-games-and-mods)
|
|
|
|
|
- [Where are mods stored?](#where-are-mods-stored)
|
2022-07-31 19:20:24 +03:00
|
|
|
|
- [Creating your first mod](#creating-your-first-mod)
|
|
|
|
|
- [Mod directory](#mod-directory)
|
|
|
|
|
- [mod.conf](#modconf)
|
|
|
|
|
- [init.lua](#initlua)
|
|
|
|
|
- [Summary](#summary)
|
|
|
|
|
- [Dependencies](#dependencies)
|
2019-05-31 20:32:40 +03:00
|
|
|
|
- [Mod Packs](#mod-packs)
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-09-20 21:12:18 +03:00
|
|
|
|
|
|
|
|
|
## What are Games and Mods?
|
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
The power of Minetest is the ability to easily develop games without the need
|
2018-10-27 05:10:37 +03:00
|
|
|
|
to create your own voxel graphics, voxel algorithms, or fancy networking code.
|
2018-09-20 21:12:18 +03:00
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
In Minetest, a game is a collection of modules which work together to provide the
|
|
|
|
|
content and behaviour of a game.
|
2018-09-20 21:12:18 +03:00
|
|
|
|
A module, commonly known as a mod, is a collection of scripts and resources.
|
2018-10-05 00:33:04 +03:00
|
|
|
|
It's possible to make a game using only one mod, but this is rarely done because it
|
|
|
|
|
reduces the ease by which parts of the game can be adjusted and replaced
|
|
|
|
|
independently of others.
|
2018-09-20 21:12:18 +03:00
|
|
|
|
|
|
|
|
|
It's also possible to distribute mods outside of a game, in which case they
|
2018-10-05 00:33:04 +03:00
|
|
|
|
are also *mods* in the more traditional sense - modifications. These mods adjust
|
|
|
|
|
or extend the features of a game.
|
|
|
|
|
|
|
|
|
|
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,
|
2018-09-20 21:12:18 +03:00
|
|
|
|
and is applicable for both game developers and modders.
|
|
|
|
|
|
2019-03-25 21:04:09 +03:00
|
|
|
|
|
|
|
|
|
## Where are mods stored?
|
|
|
|
|
|
|
|
|
|
<a name="mod-locations"></a>
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
Each mod has its own directory where its Lua code, textures, models, and
|
2022-07-31 19:20:24 +03:00
|
|
|
|
sounds are placed. Minetest checks in several different locations for
|
2019-03-25 21:04:09 +03:00
|
|
|
|
mods. These locations are commonly called *mod load paths*.
|
|
|
|
|
|
|
|
|
|
For a given world/save game, three mod locations are checked.
|
|
|
|
|
They are, in order:
|
|
|
|
|
|
|
|
|
|
1. Game mods. These are the mods that form the game that the world is running.
|
|
|
|
|
Eg: `minetest/games/minetest_game/mods/`, `/usr/share/minetest/games/minetest/`
|
|
|
|
|
2. Global mods, the location to which mods are nearly always installed to.
|
|
|
|
|
If in doubt, place them here.
|
|
|
|
|
Eg: `minetest/mods/`
|
|
|
|
|
3. World mods, the location to store mods which are specific to a
|
|
|
|
|
particular world.
|
|
|
|
|
Eg: `minetest/worlds/world/worldmods/`
|
|
|
|
|
|
2021-05-08 23:13:25 +03:00
|
|
|
|
`minetest` is the user-data directory. You can find the location of the
|
|
|
|
|
user-data directory by opening up Minetest and clicking
|
|
|
|
|
"Open User Data Directory" in the Credits tab.
|
|
|
|
|
|
|
|
|
|
When loading mods, Minetest will check each of the above locations in order.
|
|
|
|
|
If it encounters a mod with a name the same as one found previously, the later
|
|
|
|
|
mod will be loaded in place of the earlier mod. This means that you can override
|
|
|
|
|
game mods by placing a mod with the same name in the global mod location.
|
|
|
|
|
|
2019-03-25 21:04:09 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
## Creating your first mod
|
2017-09-03 03:48:06 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
### Mod directory
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
Go to the global mods directory (About > Open user data directory > mods) and
|
|
|
|
|
create a new folder called "mymod". `mymod` is the mod name.
|
|
|
|
|
|
|
|
|
|
Each mod should have a unique *mod name*, a technical identifier (id) used to
|
|
|
|
|
refer to the mod. Mod names can include letters, numbers, and underscores. A
|
|
|
|
|
good name should describe what the mod does, and the directory that contains
|
|
|
|
|
the components of a mod must have the same name as the mod name. To find out if
|
|
|
|
|
a mod name is available, try searching for it on
|
2018-09-14 17:00:44 +03:00
|
|
|
|
[content.minetest.net](https://content.minetest.net).
|
2014-12-18 21:57:13 +03:00
|
|
|
|
|
2018-09-15 19:04:19 +03:00
|
|
|
|
mymod
|
2022-07-31 19:20:24 +03:00
|
|
|
|
├── textures
|
|
|
|
|
│ └── mymod_node.png files
|
|
|
|
|
├── init.lua
|
|
|
|
|
└── mod.conf
|
|
|
|
|
|
|
|
|
|
Mods only require an init.lua file;
|
2018-09-14 17:00:44 +03:00
|
|
|
|
however, mod.conf is recommended and other components may be needed
|
2018-10-05 00:33:04 +03:00
|
|
|
|
depending on the mod's functionality.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
### mod.conf
|
|
|
|
|
|
|
|
|
|
Create a mod.conf file with the following content:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
name = mymod
|
|
|
|
|
description = Adds foo, bar, and bo.
|
|
|
|
|
depends = default
|
|
|
|
|
```
|
2019-03-25 21:04:09 +03:00
|
|
|
|
|
2020-12-24 16:25:31 +03:00
|
|
|
|
This file is used for mod metadata including the mod's name, description, and other
|
|
|
|
|
information.
|
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
### init.lua
|
2020-12-24 16:25:31 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
Create an init.lua file with the following content:
|
2020-12-24 16:25:31 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
```lua
|
|
|
|
|
print("This file will be run at load time!")
|
|
|
|
|
|
2024-10-23 02:39:22 +03:00
|
|
|
|
core.register_node("mymod:node", {
|
2022-07-31 19:20:24 +03:00
|
|
|
|
description = "This is a node",
|
|
|
|
|
tiles = {"mymod_node.png"},
|
|
|
|
|
groups = {cracky = 1}
|
|
|
|
|
})
|
|
|
|
|
|
2024-10-23 02:39:22 +03:00
|
|
|
|
core.register_craft({
|
2022-07-31 19:20:24 +03:00
|
|
|
|
type = "shapeless",
|
|
|
|
|
output = "mymod:node 3",
|
|
|
|
|
recipe = { "default:dirt", "default:stone" },
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The init.lua file is the entrypoint to a mod, and runs when the mod is loaded.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This mod has the name "mymod". It has two text files: init.lua and mod.conf. The
|
|
|
|
|
script prints a message and then registers a node and a craft recipe – these
|
|
|
|
|
will be explained later on. There's a single dependency, the
|
|
|
|
|
[default mod](https://content.minetest.net/metapackages/default/), which is
|
|
|
|
|
usually found in Minetest Game. There is also a texture in textures/ for the
|
|
|
|
|
node.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Dependencies
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
A dependency occurs when a mod requires another mod to be loaded before itself.
|
2022-07-31 19:20:24 +03:00
|
|
|
|
One mod may require another mod's code, items, or other resources to be
|
|
|
|
|
available for it to use.
|
2018-10-05 00:33:04 +03:00
|
|
|
|
|
2018-09-14 17:00:44 +03:00
|
|
|
|
There are two types of dependencies: hard and optional dependencies.
|
2018-10-05 00:33:04 +03:00
|
|
|
|
Both require the mod to be loaded first. If the mod being depended on isn't
|
|
|
|
|
available, a hard dependency will cause the mod to fail to load, while an optional
|
|
|
|
|
dependency might lead to fewer features being enabled.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2022-07-31 19:20:24 +03:00
|
|
|
|
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.
|
2018-09-14 17:00:44 +03:00
|
|
|
|
|
2020-12-24 16:25:31 +03:00
|
|
|
|
Dependencies are specified in a comma-separated list in mod.conf.
|
2018-09-14 17:00:44 +03:00
|
|
|
|
|
|
|
|
|
depends = modone, modtwo
|
|
|
|
|
optional_depends = modthree
|
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
|
## Mod Packs
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2020-12-24 16:25:31 +03:00
|
|
|
|
Mods can be grouped into mod packs, which allow multiple mods to be packaged
|
2017-09-03 03:48:06 +03:00
|
|
|
|
and moved together. They are useful if you want to supply multiple mods to
|
2018-10-05 00:33:04 +03:00
|
|
|
|
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
|
2021-03-27 19:02:32 +03:00
|
|
|
|
├── modpack.conf (required) - signals that this is a mod pack
|
2018-09-15 19:04:19 +03:00
|
|
|
|
├── mod1
|
|
|
|
|
│ └── ... mod files
|
|
|
|
|
└── mymod (optional)
|
|
|
|
|
└── ... mod files
|
|
|
|
|
|
2018-10-05 00:33:04 +03:00
|
|
|
|
Please note that a modpack is not a *game*.
|
|
|
|
|
Games have their own organisational structure which will be explained in the
|
|
|
|
|
Games chapter.
|