Difference between revisions of "Modding Intro"

From Minetest Developer Wiki
Jump to navigation Jump to search
(update html lua_api link)
 
(35 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{ModdingIntro}}
+
Minetest has a scripting '''API''', which is used to program games and mods, creating whole new experiences or extending existing ones.
  
== Intro ==
+
The API is accessed using Lua, an easy-to-use programming language.
 +
Version 5.1 of Lua is used, but many people run LuaJIT for greater performance.
  
Minetest has a scripting [http://en.wikipedia.org/wiki/Application_programming_interface API] ('''A'''pplication '''P'''rogramming '''I'''nterface), which is used to program '''mods''' (short for "modifications") for the game, extending its features and adding new items.
+
The only thing you will need is ''basic'' programming knowledge.
  
This API is accessed using an easy-to-use programming language called Lua.
+
== Documentation ==
  
The only thing you will need is basic programming knowledge. If you don't have any programming experience, you can use http://codecademy.com to learn. It will teach you the basics of programming (it is JavaScript, not Lua, but still helps).
+
=== Tutorials ===
 +
The [https://rubenwardy.com/minetest_modding_book/ Minetest Modding Book] is a friendly introduction to Minetest modding and game creation, introducing you to various aspects of the API.
  
More specifically, the version of Lua is 5.1. [http://www.lua.org/manual/5.1/ Reference manual], [http://www.lua.org/pil/ book]
+
It is recommended you start here, even if you are already apt at programming, to get a good understanding of how Minetest mods work and are structured.
  
== Example ==
+
=== Lua API Reference ===
<source>
+
The official Lua API documentation is <code>lua_api.md</code>. It's available as [https://github.com/minetest/minetest/blob/master/doc/lua_api.md markdown] or [https://api.minetest.net/ HTML]. You can find the plaintext version in your Minetest installation, in the <code>doc</code> directory.
-- Add the decowood node
 
minetest.register_node("tutorial:decowood", {
 
tiles = {"tutorial_decowood.png"},
 
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
 
})
 
  
-- Add the decostick craftitem
+
This is a concise description of the entire API, explaining functions, data structures, registration templates & more. The core developers of minetest maintain it, changes going through a quality control process.
minetest.register_craftitem("tutorial:decostick", {
 
inventory_image = "tutorial_decostick.png",
 
groups = {stick=1},
 
})
 
  
-- Add the crafting recipe for decowood
+
Any functions not listed here are subject to change and not guaranteed to be compatible across versions, though usually they are.
minetest.register_craft({
 
output = 'tutorial:decowood 2',
 
recipe = {
 
{'default:wood', 'default:wood', ''},
 
{'default:wood', 'default:wood', ''},
 
{'', '', ''},
 
}
 
})
 
  
-- Add the furnace recipe for decosticks
+
=== The Minetest-Docs Project ===
minetest.register_craft({
+
A work-in-progress project is underway to create new, more detailed, documentation. They can be read from its [https://github.com/minetest/minetest_docs/ GitHub repo], contributions are greatly appreciated.
type = "cooking",
+
 
recipe = "tutorial:decowood",
+
 
output = "tutorial:decostick",
+
== Useful tools ==
})
+
Here are some useful tools that most modders use when making Minetest mods:
</source>
+
 
== Next ==
+
* [https://code.visualstudio.com/ Visual Studio Code]/[https://vscodium.com/ VSCodium], powerful code editor with a [https://marketplace.visualstudio.com/items?itemName=GreenXenith.minetest-tools Minetest extension] available for code completion.
Learn how to actually set up an environment to start modding in the next section! [[Modding_Setup]]
+
* [https://github.com/lunarmodules/luacheck luacheck], static analysis tool for Lua. See [https://rubenwardy.com/minetest_modding_book/en/quality/luacheck.html this modding book chapter] for more information on how to use it with Minetest.
[[Category:Mods]]
+
 
 +
== Other useful links ==
 +
* Check out [https://content.minetest.net/ ContentDB] to see mods that have been published by the community.
 +
* Get mod help from the community:
 +
** [https://forum.minetest.net/viewforum.php?f=47 Forums]
 +
** [https://discord.gg/minetest Discord]
 +
** [https://matrix.to/#/#minetest:tchncs.de Matrix]
 +
** ...[https://www.minetest.net/get-involved/ more]
 +
* Suggest a mod idea in the [https://forum.minetest.net/viewtopic.php?f=9&t=2434 mod request thread].
 +
 
 +
[[Category:Modding API]]

Latest revision as of 16:44, 18 September 2023

Minetest has a scripting API, which is used to program games and mods, creating whole new experiences or extending existing ones.

The API is accessed using Lua, an easy-to-use programming language. Version 5.1 of Lua is used, but many people run LuaJIT for greater performance.

The only thing you will need is basic programming knowledge.

Documentation

Tutorials

The Minetest Modding Book is a friendly introduction to Minetest modding and game creation, introducing you to various aspects of the API.

It is recommended you start here, even if you are already apt at programming, to get a good understanding of how Minetest mods work and are structured.

Lua API Reference

The official Lua API documentation is lua_api.md. It's available as markdown or HTML. You can find the plaintext version in your Minetest installation, in the doc directory.

This is a concise description of the entire API, explaining functions, data structures, registration templates & more. The core developers of minetest maintain it, changes going through a quality control process.

Any functions not listed here are subject to change and not guaranteed to be compatible across versions, though usually they are.

The Minetest-Docs Project

A work-in-progress project is underway to create new, more detailed, documentation. They can be read from its GitHub repo, contributions are greatly appreciated.


Useful tools

Here are some useful tools that most modders use when making Minetest mods:

Other useful links