Difference between revisions of "Modding FAQ"

From Minetest Developer Wiki
Jump to navigation Jump to search
Line 50: Line 50:
  
 
== How Do I Generate a Custom Map? ==
 
== How Do I Generate a Custom Map? ==
First, there are a bunch of [[Mapgen Parameters|mapgen parameters]] you can change for the built-in mapgens, so you might be able to get what you want without touching Lua at all.  You may also be able to find an existing mod that does what you want, so check the [http://wiki.minetest.net/Mod_list mod list] on the main Minetest Wiki and the [https://forum.minetest.net/viewforum.php?f=11 Mod Releases] section of the forums (the community has already written several mods for various map generation, importing real-world data, editing sections of existing worlds, etc.).  Finally, the Lua modding API has recently been enhanced to make custom mapgens more feasible to write without modifying the core Minetest engine.  It's not for the feint of heart but if you want to dive in, start by reading up on:
+
First, there are a bunch of [[Mapgen Parameters|mapgen parameters]] you can change for the built-in mapgens, so you might be able to get what you want without touching Lua at all.  You may also be able to find an existing mod that does what you want, so check the [http://wiki.minetest.net/Mod_list mod list] on the main Minetest Wiki and the [https://forum.minetest.net/viewforum.php?f=11 Mod Releases] section of the forums (the community has already written several mods for various map generation, importing real-world data, editing sections of existing worlds, etc.).  Finally, the Lua modding API has recently been enhanced to make custom mapgens more feasible to write without modifying the core Minetest engine.  It's not for the faint of heart but if you want to dive in, start by reading up on:
 
* [[:Category:Mapgen]]
 
* [[:Category:Mapgen]]
 
* [[VoxelManip]]: the voxel manipulator, for fast modification of large chunks of nodes.
 
* [[VoxelManip]]: the voxel manipulator, for fast modification of large chunks of nodes.

Revision as of 05:49, 11 August 2015

Basic Modding

What is a Mod

Mods (short for modifications) are user-created modifications to the game in such a way that alters gameplay. Some larger mods may add a lot of content to the game, while other smaller mods may add more settings/customization options, or optimize the speed, gameplay or graphics of Minetest. Server mods or plugins mainly give server admins more options and ease of use, and all mods for single-player can also be used in multiplayer.

Read More

Installing Mods

See Installing Mods


Where Do I Find Tutorials and Documentation About Modding?

(related Category:Modding API‏‎)
Start on the Main Page here at the Minetest Developer Wiki. It isn't just about changing the Minetest (C++) core program. There are articles and references about modding you can find right from the main page. Look for the "Develop a mod" and "Modding API" headings.

  • Introduction to the modding API on the wiki.
  • Minetest Modding Book an online clear and easy guide in learning to make mods.
  • lua_api.txt in minetest/docs/ contains an API Listing (HTML Version). Those links are to the latest development version, look in your docs/ folder for one specific to your Minetest version.
  • Youtube tutorials Probably the largest collection of Minetest video tutorials available online.
  • Search the forum by web search (eg: googling) like this: "some search terms site:forum.minetest.net".
  • Ask the community for help in the Modding General section of the forum.

The Developer Wiki is very much a community project, so don't forget to come back and help document what you find!

How Do I Debug My Mod?

The "lua" interpreter is not very useful for debugging mod code, because mods are built to run in an environment specific to Minetest (they expect to be loaded after their dependencies, have access to the Minetest API, etc.). However, you may be able to break pieces of your logic into separate, stand-alone Lua library files that are not specific to Minetest. Where you have an opportunity to do this, testing outside of Minetest (using Lua 5.1's "lua" interpreter or LuaJIT's "luajit" interpreter) can be helpful. This might work for some utility functions and "class libraries".

There is no debugger built into Minetest itself, but there are a few functions that can help (see Category:Debugging). Using these functions is generally equivalent to using "printf style debugging", meaning you'll have to modify your mod code and restart the server when you want to deduce what is going on, or carefully plan for debug logging in your code and provide some kind of debug level or flags. There is also a LuaCmd mod that allows players having adequate permissions to execute Lua statements from Minetest's chat console, but using it to examine the state of your mod is limited to your public API (in other words, functions and variables you have put in a global table named after your mod, rather than local variables defined in your mod files).

Specific Questions Regarding Node Definitions


General Information on Registering Nodes

See minetest.register_node.

How can I make my new nodes transparent in certain sections?


To make a node have transparent patches, you need to do two things: Have your image texture be transparent where you need it to be, and second, you need to specify the node's drawtype to be one of the following: "glasslike", "glasslike_framed", "allfaces", or "allfaces_optional".

What if I only want it partially transparent, such as with tinted glass?


To do this, add use_texture_alpha = true to the node definition while following the directions above.

How Do I Generate a Custom Map?

First, there are a bunch of mapgen parameters you can change for the built-in mapgens, so you might be able to get what you want without touching Lua at all. You may also be able to find an existing mod that does what you want, so check the mod list on the main Minetest Wiki and the Mod Releases section of the forums (the community has already written several mods for various map generation, importing real-world data, editing sections of existing worlds, etc.). Finally, the Lua modding API has recently been enhanced to make custom mapgens more feasible to write without modifying the core Minetest engine. It's not for the faint of heart but if you want to dive in, start by reading up on:

This is a pretty advanced task to do in a mod, so expect to also have to do some digging and research in the lua_api.txt document.

Advanced Modding