2014-12-11 11:56:37 +03:00
|
|
|
|
---
|
2014-12-11 23:04:07 +03:00
|
|
|
|
title: Folder Structure
|
2014-12-11 11:56:37 +03:00
|
|
|
|
layout: default
|
2017-08-26 18:40:30 +03:00
|
|
|
|
root: ../../
|
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
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
* [Mod Folders](#mod-folders)
|
|
|
|
|
* [Dependencies](#dependencies)
|
|
|
|
|
* [Mod Packs](#mod-packs)
|
|
|
|
|
* [Example](#example)
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
|
## Mod Folders
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-11-08 18:57:40 +03:00
|
|
|
|
Each mod has its own folder where all its Lua code, textures, models, and sounds
|
|
|
|
|
are placed. These folders need to be placed in a mod location such as
|
2017-09-03 03:48:06 +03:00
|
|
|
|
minetest/mods.
|
|
|
|
|
|
|
|
|
|
![Find the mod's folder]({{ page.root }}/static/folder_modfolder.jpg)
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
A "mod name" is used to refer to a mod. Each mod should have a unique mod name.
|
|
|
|
|
Mod names can include letters, numbers, and underscores. A good mod name should
|
|
|
|
|
describe what the mod does, and the folder which contains the components of a mod
|
|
|
|
|
needs to be given the same name as the mod name.
|
2014-12-18 21:57:13 +03:00
|
|
|
|
|
2014-12-11 11:56:37 +03:00
|
|
|
|
### Mod Folder Structure
|
2017-08-26 21:01:51 +03:00
|
|
|
|
Mod name (eg: "mymod")
|
2017-09-03 03:48:06 +03:00
|
|
|
|
- init.lua - the main scripting code file, which runs when the game loads.
|
|
|
|
|
- (optional) depends.txt - a list of mods that need to be loaded before this mod.
|
|
|
|
|
- (optional) textures/ - images used by the mod, commonly in the format modname_itemname.png.
|
|
|
|
|
- (optional) sounds/ - sounds used by the mod.
|
|
|
|
|
- (optional) models/ - 3d models used by the mod.
|
|
|
|
|
...and any other Lua files to be included.
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-11-08 18:57:40 +03:00
|
|
|
|
Only the init.lua file is required in a mod for it to run on game load; however,
|
2015-02-19 17:55:37 +03:00
|
|
|
|
the other items are needed by some mods to perform their 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
|
|
|
|
|
2015-11-08 18:57:40 +03:00
|
|
|
|
The depends text file allows you to specify which mods this mod requires to run and what
|
2014-12-11 11:56:37 +03:00
|
|
|
|
needs to be loaded before this mod.
|
|
|
|
|
|
2014-12-31 19:51:24 +03:00
|
|
|
|
**depends.txt**
|
|
|
|
|
|
2017-08-26 21:01:51 +03:00
|
|
|
|
modone
|
|
|
|
|
modtwo
|
|
|
|
|
modthree?
|
2014-12-11 11:56:37 +03:00
|
|
|
|
|
2015-02-19 17:55:37 +03:00
|
|
|
|
As you can see, 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
|
|
|
|
|
|
|
|
|
### Mod Pack Folder Structure
|
2017-08-26 21:01:51 +03:00
|
|
|
|
modpackfolder/
|
|
|
|
|
- modone/
|
|
|
|
|
- modtwo/
|
|
|
|
|
- modthree/
|
|
|
|
|
- modfour/
|
|
|
|
|
- modpack.txt – signals that this is a mod pack, content does not matter
|
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
|
2017-08-26 21:01:51 +03:00
|
|
|
|
mymod/
|
|
|
|
|
- textures/
|
|
|
|
|
- - mymod_node.png
|
|
|
|
|
- init.lua
|
|
|
|
|
- depends.txt
|
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
|
|
|
|
|
{% highlight 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
|
|
|
|
})
|
2014-12-11 11:56:37 +03:00
|
|
|
|
{% endhighlight %}
|
|
|
|
|
|
2017-09-03 03:48:06 +03:00
|
|
|
|
This mod has the name "mymod". It has two text files: init.lua and depends.txt.\\
|
2015-02-24 12:30:05 +03:00
|
|
|
|
The script prints a message and then registers a node – which will be explained in the next chapter.\\
|
2017-09-03 03:48:06 +03:00
|
|
|
|
The depends text file adds a dependency on the default mod which is in minetest_game.\\
|
2015-02-24 12:30:05 +03:00
|
|
|
|
There is also a texture in textures/ for the node.
|