* More information at <http://www.minetest.net/>
* Developer Wiki: <http://dev.minetest.net/>
-
Introduction
-============
+------------
Content and functionality can be added to Minetest using Lua scripting
in run-time loaded mods.
--------
Mods can be put in a subdirectory, if the parent directory, which otherwise
-should be a mod, contains a file named `modpack.txt`. This file shall be
-empty, except for lines starting with `#`, which are comments.
+should be a mod, contains a file named `modpack.conf`.
+The file is a key-value store of modpack details.
+
+* `name`: The modpack name.
+* `description`: Description of mod to be shown in the Mods tab of the main
+ menu.
+
+Note: to support 0.4.x, please also create an empty modpack.txt file.
Mod directory structure
-----------------------
Aliases
=======
-Aliases can be added by using `minetest.register_alias(name, convert_to)` or
-`minetest.register_alias_force(name, convert_to)`.
+Aliases of itemnames can be added by using
+`minetest.register_alias(alias, original_name)` or
+`minetest.register_alias_force(alias, original_name)`.
-This converts anything called `name` to `convert_to`.
+This adds an alias `alias` for the item called `original_name`.
+From now on, you can use `alias` to refer to the item `original_name`.
The only difference between `minetest.register_alias` and
-`minetest.register_alias_force` is that if an item called `name` exists,
+`minetest.register_alias_force` is that if an item named `alias` already exists,
`minetest.register_alias` will do nothing while
`minetest.register_alias_force` will unregister it.
}
Looped sounds must either be connected to an object or played locationless to
-one player using `to_player = name,`
+one player using `to_player = name,`.
+
+A positional sound will only be heard by players that are within
+`max_hear_distance` of the sound position, at the start of the sound.
`SimpleSoundSpec`
-----------------
Registered definitions
======================
-Anything added using certain `minetest.register_*` functions gets added to
-the global `minetest.registered_*` tables.
-
-* `minetest.register_entity(name, entity definition)`
- * added to `minetest.registered_entities[name]`
-
-* `minetest.register_node(name, node definition)`
- * added to `minetest.registered_items[name]`
- * added to `minetest.registered_nodes[name]`
-
-* `minetest.register_tool(name, item definition)`
- * added to `minetest.registered_items[name]`
-
-* `minetest.register_craftitem(name, item definition)`
- * added to `minetest.registered_items[name]`
-
-* `minetest.unregister_item(name)`
- * Unregisters the item name from engine, and deletes the entry with key
- `name` from `minetest.registered_items` and from the associated item
- table according to its nature: `minetest.registered_nodes[]` etc
-
-* `minetest.register_biome(biome definition)`
- * returns an integer uniquely identifying the registered biome
- * added to `minetest.registered_biome` with the key of `biome.name`
- * if `biome.name` is nil, the key is the returned ID
-
-* `minetest.unregister_biome(name)`
- * Unregisters the biome name from engine, and deletes the entry with key
- `name` from `minetest.registered_biome`
-
-* `minetest.register_ore(ore definition)`
- * returns an integer uniquely identifying the registered ore
- * added to `minetest.registered_ores` with the key of `ore.name`
- * if `ore.name` is nil, the key is the returned ID
-
-* `minetest.register_decoration(decoration definition)`
- * returns an integer uniquely identifying the registered decoration
- * added to `minetest.registered_decorations` with the key of
- `decoration.name`.
- * if `decoration.name` is nil, the key is the returned ID
-
-* `minetest.register_schematic(schematic definition)`
- * returns an integer uniquely identifying the registered schematic
- * added to `minetest.registered_schematic` with the key of `schematic.name`
- * if `schematic.name` is nil, the key is the returned ID
- * if the schematic is loaded from a file, schematic.name is set to the
- filename.
- * if the function is called when loading the mod, and schematic.name is a
- relative path, then the current mod path will be prepended to the
- schematic filename.
-
-* `minetest.clear_registered_biomes()`
- * clears all biomes currently registered
-
-* `minetest.clear_registered_ores()`
- * clears all ores currently registered
-
-* `minetest.clear_registered_decorations()`
- * clears all decorations currently registered
-
-* `minetest.clear_registered_schematics()`
- * clears all schematics currently registered
+Anything added using certain [Registration functions] gets added to one or more
+of the global [Registered definition tables].
Note that in some cases you will stumble upon things that are not contained
in these tables (e.g. when a mod has been removed). Always check for
existence before trying to access the fields.
-Example: If you want to check the drawtype of a node, you could do:
+Example:
+
+All nodes register with `minetest.register_node` get added to the table
+`minetest.registered_nodes`.
+
+If you want to check the drawtype of a node, you could do:
local function get_nodedef_field(nodename, fieldname)
if not minetest.registered_nodes[nodename] then
* `glasslike_framed`
* All face-connected nodes are drawn as one volume within a surrounding
frame.
- * The frame appearence is generated from the edges of the first texture
+ * The frame appearance is generated from the edges of the first texture
specified in `tiles`. The width of the edges used are 1/16th of texture
size: 1 pixel for 16x16, 2 pixels for 32x32 etc.
* The glass 'shine' (or other desired detail) on each node face is supplied
+Map terminology and coordinates
+===============================
+
+Nodes, mapblocks, mapchunks
+---------------------------
+
+A 'node' is the fundamental cubic unit of a world and appears to a player as
+roughly 1x1x1 meters in size.
+
+A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
+fundamental region of a world that is stored in the world database, sent to
+clients and handled by many parts of the engine.
+'mapblock' is preferred terminology to 'block' to help avoid confusion with
+'node', however 'block' often appears in the API.
+
+A 'mapchunk' (sometimes abbreviated to 'chunk') is usually 5x5x5 mapblocks
+(80x80x80 nodes) and is the volume of world generated in one operation by
+the map generator.
+The size in mapblocks has been chosen to optimise map generation.
+
+Coordinates
+-----------
+
+### Orientation of axes
+
+For node and mapblock coordinates, +X is East, +Y is up, +Z is North.
+
+### Node coordinates
+
+Almost all positions used in the API use node coordinates.
+
+### Mapblock coordinates
+
+Occasionally the API uses 'blockpos' which refers to mapblock coordinates that
+specify a particular mapblock.
+For example blockpos (0,0,0) specifies the mapblock that extends from
+node position (0,0,0) to node position (15,15,15).
+
+#### Converting node position to the containing blockpos
+
+To calculate the blockpos of the mapblock that contains the node at 'nodepos',
+for each axis:
+
+* blockpos = math.floor(nodepos / 16)
+
+#### Converting blockpos to min/max node positions
+
+To calculate the min/max node positions contained in the mapblock at 'blockpos',
+for each axis:
+
+* Minimum:
+ nodepos = blockpos * 16
+* Maximum:
+ nodepos = blockpos * 16 + 15
+
+
+
+
HUD
===
`0` draws from left to right, `1` draws from right to left, `2` draws from
top to bottom, and `3` draws from bottom to top.
-The `alignment` field specifies how the item will be aligned. It ranges from
-`-1` to `1`, with `0` being the center. `-1` is moved to the left/up, and `1`
-is to the right/down. Fractional values can be used.
+The `alignment` field specifies how the item will be aligned. It is a table
+where `x` and `y` range from `-1` to `1`, with `0` being central. `-1` is
+moved to the left/up, and `1` is to the right/down. Fractional values can be
+used.
The `offset` field specifies a pixel offset from the position. Contrary to
position, the offset is not scaled to screen size. This allows for some
type are ignored.
### `image`
+
Displays an image on the HUD.
* `scale`: The scale of the image, with 1 being the original texture size.
* `{type="object", ref=ObjectRef}`
Exact pointing location (currently only `Raycast` supports these fields):
+
* `pointed_thing.intersection_point`: The absolute world coordinates of the
point on the selection box which is pointed at. May be in the selection box
if the pointer is in the box too.
* `fall_damage_add_percent`: damage speed = `speed * (1 + value/100)`
* `bouncy`: value is bounce speed in percent
* `falling_node`: if there is no walkable block under the node it will fall
+* `float`: the node will not fall through liquids
* `attached_node`: if the node under it is not a walkable block the node will be
dropped as an item. If the node is wallmounted the wallmounted direction is
checked.
-* `soil`: saplings will grow on nodes in this group
* `connect_to_raillike`: makes nodes of raillike drawtype with same group value
connect to each other
* `slippery`: Players and items will slide on the node.
Slipperiness rises steadily with `slippery` value, starting at 1.
-
+* `disable_repair`: If set to 1 for a tool, it cannot be repaired using the
+ `"toolrepair"` crafting recipe
Known damage and digging time defining groups
---------------------------------------------
Formspec
========
-Formspec defines a menu. Currently not much else than inventories are
-supported. It is a string, with a somewhat strange format.
+Formspec defines a menu. This supports inventories and some of the
+typical widgets like buttons, checkboxes, text input fields, etc.
+It is a string, with a somewhat strange format.
+
+A formspec is made out of formspec elements, which includes widgets
+like buttons but also can be used to set stuff like background color.
+
+Many formspec elements have a `name`, which is a unique identifier which
+is used when the server receives user input. You must not use the name
+"quit" for formspec elements.
Spaces and newlines can be inserted between the blocks, as is used in the
examples.
Position and size units are inventory slots, `X` and `Y` position the formspec
element relative to the top left of the menu or container. `W` and `H` are its
width and height values.
+Inventories with a `player:<name>` inventory location are only sent to the
+player named `<name>`.
+
When displaying text which can contain formspec code, e.g. text set by a player,
use `minetest.formspec_escape`.
For coloured text you can use `minetest.colorize`.
### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]`
-* Show an inventory list
+* Show an inventory list if it has been sent to the client. Nothing will
+ be shown if the inventory list is of size 0.
### `list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]`
-* Show an inventory list
+* Show an inventory list if it has been sent to the client. Nothing will
+ be shown if the inventory list is of size 0.
### `listring[<inventory location>;<list name>]`
* `<fontcolor>` tooltip font color as `ColorString` (optional)
### `tooltip[<X>,<Y>;<W>,<H>;<tooltip_text>;<bgcolor>;<fontcolor>]`
+
* Adds tooltip for an area. Other tooltips will take priority when present.
* `<bgcolor>` tooltip background color as `ColorString` (optional)
* `<fontcolor>` tooltip font color as `ColorString` (optional)
### `item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]`
-* `item name` is the registered name of an item/node,
- tooltip will be made out of its description
- to override it use tooltip element
+* `item name` is the registered name of an item/node
+* The item description will be used as the tooltip. This can be overridden with
+ a tooltip element.
### `button_exit[<X>,<Y>;<W>,<H>;<name>;<label>]`
Spatial Vectors
===============
+A spatial vector is similar to a position, but instead using
+absolute world coordinates, it uses *relative* coordinates, relative to
+no particular point.
+
+Internally, it is implemented as a table with the 3 fields
+`x`, `y` and `z`. Example: `{x = 0, y = 1, z = 0}`.
For the following functions, `v`, `v1`, `v2` are vectors,
`p1`, `p2` are positions:
* Returns a boolean, `true` if the vectors are identical.
* `vector.sort(v1, v2)`:
* Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
+* `vector.angle(v1, v2)`:
+ * Returns the angle between `v1` and `v2` in radians.
For the following functions `x` can be either a vector or a number:
* `vector.add(v, x)`:
* Returns a vector.
+ * If `x` is a vector: Returns the sum of `v` and `x`.
+ * If `x` is a number: Adds `x` to each component of `v`.
* `vector.subtract(v, x)`:
* Returns a vector.
+ * If `x` is a vector: Returns the difference of `v` subtracted by `x`.
+ * If `x` is a number: Subtracts `x` from each component of `v`.
* `vector.multiply(v, x)`:
* Returns a scaled vector or Schur product.
* `vector.divide(v, x)`:
* tolerance: number, default: `0.0`
* If the absolute value of `x` is within the `tolerance` or `x` is NaN,
`0` is returned.
+* `math.factorial(x)`: returns the factorial of `x`
* `string.split(str, separator, include_empty, max_splits, sep_is_pattern)`
* `separator`: string, default: `","`
* `include_empty`: boolean, default: `false`
* returns time with microsecond precision. May not return wall time.
* `table.copy(table)`: returns a table
* returns a deep copy of `table`
+* `table.indexof(list, val)`: returns the smallest numerical index containing
+ the value `val` in the table `list`. Non-numerical indices are ignored.
+ If `val` could not be found, `-1` is returned. `list` must not have
+ negative indices.
* `table.insert_all(table, other_table)`:
* Appends all values in `other_table` to `table` - uses `#table + 1` to
find new indices.
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a
position.
* returns the exact position on the surface of a pointed node
+* `minetest.get_dig_params(groups, tool_capabilities)`: Simulates a tool
+ that digs a node.
+ Returns a table with the following fields:
+ * `diggable`: `true` if node can be dug, `false` otherwise.
+ * `time`: Time it would take to dig the node.
+ * `wear`: How much wear would be added to the tool.
+ `time` and `wear` are meaningless if node's not diggable
+ Parameters:
+ * `groups`: Table of the node groups of the node that would be dug
+ * `tool_capabilities`: Tool capabilities table of the tool
+* `minetest.get_hit_params(groups, tool_capabilities [, time_from_last_punch])`:
+ Simulates an item that punches an object.
+ Returns a table with the following fields:
+ * `hp`: How much damage the punch would cause.
+ * `wear`: How much wear would be added to the tool.
+ Parameters:
+ * `groups`: Damage groups of the object
+ * `tool_capabilities`: Tool capabilities table of the item
+ * `time_from_last_punch`: time in seconds since last punch action
Once the internal VoxelManip state has been modified to your liking, the
changes can be committed back to the map by calling `VoxelManip:write_to_map()`
-
### Flat array format
Let
* To be used only by a `VoxelManip` object from
`minetest.get_mapgen_object`.
* (`p1`, `p2`) is the area in which lighting is set, defaults to the whole
- area if left out or nil.
+ area if left out or nil. For almost all uses these should be left out
+ or nil to use the default.
* `propagate_shadow` is an optional boolean deciding whether shadows in a
generated mapchunk above are propagated down into the mapchunk, defaults
to `true` if left out.
* Called on every server tick, after movement and collision processing.
`dtime` is usually 0.1 seconds, as per the `dedicated_server_step` setting
in `minetest.conf`.
-* `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)`
+* `on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)`
* Called when somebody punches the object.
* Note that you probably want to handle most punches using the automatic
armor group system.
* `tool_capabilities`: capability table of used tool (can be `nil`)
* `dir`: unit vector of direction of punch. Always defined. Points from the
puncher to the punched.
+ * `damage`: damage that will be done to entity.
* `on_death(self, killer)`
* Called when the object dies.
* `killer`: an `ObjectRef` (can be `nil`)
* `minetest.features`: Table containing API feature flags
{
- glasslike_framed = true,
- nodebox_as_selectionbox = true,
- chat_send_player_param3 = true,
- get_all_craft_recipes_works = true,
+ glasslike_framed = true, -- 0.4.7
+ nodebox_as_selectionbox = true, -- 0.4.7
+ get_all_craft_recipes_works = true, -- 0.4.7
-- The transparency channel of textures can optionally be used on
- -- nodes
+ -- nodes (0.4.7)
use_texture_alpha = true,
- -- Tree and grass ABMs are no longer done from C++
+ -- Tree and grass ABMs are no longer done from C++ (0.4.8)
no_legacy_abms = true,
- -- Texture grouping is possible using parentheses
+ -- Texture grouping is possible using parentheses (0.4.11)
texture_names_parens = true,
- -- Unique Area ID for AreaStore:insert_area
+ -- Unique Area ID for AreaStore:insert_area (0.4.14)
area_store_custom_ids = true,
-- add_entity supports passing initial staticdata to on_activate
+ -- (0.4.16)
add_entity_with_staticdata = true,
- -- Chat messages are no longer predicted
+ -- Chat messages are no longer predicted (0.4.16)
no_chat_message_prediction = true,
-- The transparency channel of textures can optionally be used on
- -- objects (ie: players and lua entities)
+ -- objects (ie: players and lua entities) (5.0.0)
object_use_texture_alpha = true,
-- Object selectionbox is settable independently from collisionbox
+ -- (5.0.0)
object_independent_selectionbox = true,
+ -- Specifies whether binary data can be uploaded or downloaded using
+ -- the HTTP API (5.1.0)
+ httpfetch_binary_data = true,
}
* `minetest.has_feature(arg)`: returns `boolean, missing_features`
Call these functions only at load time!
-* `minetest.register_entity(name, entity definition)`
-* `minetest.register_abm(abm definition)`
-* `minetest.register_lbm(lbm definition)`
+### Environment
+
* `minetest.register_node(name, node definition)`
-* `minetest.register_tool(name, item definition)`
* `minetest.register_craftitem(name, item definition)`
+* `minetest.register_tool(name, item definition)`
+* `minetest.override_item(name, redefinition)`
+ * Overrides fields of an item registered with register_node/tool/craftitem.
+ * Note: Item must already be defined, (opt)depend on the mod defining it.
+ * Example: `minetest.override_item("default:mese",
+ {light_source=minetest.LIGHT_MAX})`
* `minetest.unregister_item(name)`
-* `minetest.register_alias(name, convert_to)`
+ * Unregisters the item from the engine, and deletes the entry with key
+ `name` from `minetest.registered_items` and from the associated item table
+ according to its nature: `minetest.registered_nodes`, etc.
+* `minetest.register_entity(name, entity definition)`
+* `minetest.register_abm(abm definition)`
+* `minetest.register_lbm(lbm definition)`
+* `minetest.register_alias(alias, original_name)`
* Also use this to set the 'mapgen aliases' needed in a game for the core
- * mapgens. See [Mapgen aliases] section above.
-* `minetest.register_alias_force(name, convert_to)`
+ mapgens. See [Mapgen aliases] section above.
+* `minetest.register_alias_force(alias, original_name)`
+* `minetest.register_ore(ore definition)`
+ * Returns an integer uniquely identifying the registered ore on success.
+ * The order of ore registrations determines the order of ore generation.
+* `minetest.register_biome(biome definition)`
+ * Returns an integer uniquely identifying the registered biome on success.
+* `minetest.unregister_biome(name)`
+ * Unregisters the biome from the engine, and deletes the entry with key
+ `name` from `minetest.registered_biomes`.
+* `minetest.register_decoration(decoration definition)`
+ * Returns an integer uniquely identifying the registered decoration on
+ success.
+ * The order of decoration registrations determines the order of decoration
+ generation.
+* `minetest.register_schematic(schematic definition)`
+ * Returns an integer uniquely identifying the registered schematic on
+ success.
+ * If the schematic is loaded from a file, the `name` field is set to the
+ filename.
+ * If the function is called when loading the mod, and `name` is a relative
+ path, then the current mod path will be prepended to the schematic
+ filename.
+* `minetest.clear_registered_ores()`
+ * Clears all ores currently registered.
+* `minetest.clear_registered_biomes()`
+ * Clears all biomes currently registered.
+* `minetest.clear_registered_decorations()`
+ * Clears all decorations currently registered.
+* `minetest.clear_registered_schematics()`
+ * Clears all schematics currently registered.
+
+### Gameplay
+
* `minetest.register_craft(recipe)`
* Check recipe table syntax for different types below.
* `minetest.clear_craft(recipe)`
ignored. For input use the same recipe table syntax as for
`minetest.register_craft(recipe)`. For output specify only the item,
without a quantity.
- * If no erase candidate could be found, Lua exception will be thrown.
+ * Returns false if no erase candidate could be found, otherwise returns true.
* **Warning**! The type field ("shaped", "cooking" or any other) will be
ignored if the recipe contains output. Erasing is then done independently
from the crafting method.
-* `minetest.register_ore(ore definition)`
-* `minetest.register_biome(biome definition)`
-* `minetest.register_decoration(decoration definition)`
-* `minetest.override_item(name, redefinition)`
- * Overrides fields of an item registered with register_node/tool/craftitem.
- * Note: Item must already be defined, (opt)depend on the mod defining it.
- * Example: `minetest.override_item("default:mese", {light_source=LIGHT_MAX})`
-* `minetest.clear_registered_ores()`
-* `minetest.clear_registered_biomes()`
-* `minetest.clear_registered_decorations()`
+* `minetest.register_chatcommand(cmd, chatcommand definition)`
+* `minetest.override_chatcommand(name, redefinition)`
+ * Overrides fields of a chatcommand registered with `register_chatcommand`.
+* `minetest.unregister_chatcommand(name)`
+ * Unregisters a chatcommands registered with `register_chatcommand`.
+* `minetest.register_privilege(name, definition)`
+ * `definition` can be a description or a definition table (see [Privilege
+ definition]).
+ * If it is a description, the priv will be granted to singleplayer and admin
+ by default.
+ * To allow players with `basic_privs` to grant, see the `basic_privs`
+ minetest.conf setting.
+* `minetest.register_authentication_handler(authentication handler definition)`
+ * Registers an auth handler that overrides the builtin one.
+ * This function can be called by a single mod once only.
Global callback registration functions
--------------------------------------
Call these functions only at load time!
-* `minetest.register_globalstep(func(dtime))`
+* `minetest.register_globalstep(function(dtime))`
* Called every server step, usually interval of 0.1s
-* `minetest.register_on_mods_loaded(func())`
+* `minetest.register_on_mods_loaded(function())`
* Called after mods have finished loading and before the media is cached or the
aliases handled.
-* `minetest.register_on_shutdown(func())`
+* `minetest.register_on_shutdown(function())`
* Called before server shutdown
* **Warning**: If the server terminates abnormally (i.e. crashes), the
registered callbacks **will likely not be run**. Data should be saved at
semi-frequent intervals as well as on server shutdown.
-* `minetest.register_on_placenode(func(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
+* `minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))`
* Called when a node has been placed
* If return `true` no item is taken from `itemstack`
* `placer` may be any valid ObjectRef or nil.
* **Not recommended**; use `on_construct` or `after_place_node` in node
definition whenever possible.
-* `minetest.register_on_dignode(func(pos, oldnode, digger))`
+* `minetest.register_on_dignode(function(pos, oldnode, digger))`
* Called when a node has been dug.
* **Not recommended**; Use `on_destruct` or `after_dig_node` in node
definition whenever possible.
-* `minetest.register_on_punchnode(func(pos, node, puncher, pointed_thing))`
+* `minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing))`
* Called when a node is punched
-* `minetest.register_on_generated(func(minp, maxp, blockseed))`
+* `minetest.register_on_generated(function(minp, maxp, blockseed))`
* Called after generating a piece of world. Modifying nodes inside the area
is a bit faster than usually.
-* `minetest.register_on_newplayer(func(ObjectRef))`
+* `minetest.register_on_newplayer(function(ObjectRef))`
* Called after a new player has been created
-* `minetest.register_on_punchplayer(func(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
+* `minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage))`
* Called when a player is punched
+ * Note: This callback is invoked even if the punched player is dead.
* `player`: ObjectRef - Player that was punched
* `hitter`: ObjectRef - Player that hit
* `time_from_last_punch`: Meant for disallowing spamming of clicks
the puncher to the punched.
* `damage`: Number that represents the damage calculated by the engine
* should return `true` to prevent the default damage mechanism
-* `minetest.register_on_player_hpchange(func(player, hp_change, reason), modifier)`
+* `minetest.register_on_player_hpchange(function(player, hp_change, reason), modifier)`
* Called when the player gets damaged or healed
* `player`: ObjectRef of the player
* `hp_change`: the amount of change. Negative when it is damage.
giving a type - use this for custom damage types.
* `punch`: Was punched. `reason.object` will hold the puncher, or nil if none.
* `fall`
- * `node_damage`: damage_per_second from a neighbouring node.
+ * `node_damage`: `damage_per_second` from a neighbouring node.
+ `reason.node` will hold the node name or nil.
* `drown`
* `respawn`
* Any of the above types may have additional fields from mods.
* `reason.from` will be `mod` or `engine`.
* `modifier`: when true, the function should return the actual `hp_change`.
- Note: modifiers only get a temporary hp_change that can be modified by later modifiers.
- modifiers can return true as a second argument to stop the execution of further functions.
- Non-modifiers receive the final hp change calculated by the modifiers.
-* `minetest.register_on_dieplayer(func(ObjectRef, reason))`
+ Note: modifiers only get a temporary `hp_change` that can be modified by later modifiers.
+ Modifiers can return true as a second argument to stop the execution of further functions.
+ Non-modifiers receive the final HP change calculated by the modifiers.
+* `minetest.register_on_dieplayer(function(ObjectRef, reason))`
* Called when a player dies
* `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange
-* `minetest.register_on_respawnplayer(func(ObjectRef))`
+* `minetest.register_on_respawnplayer(function(ObjectRef))`
* Called when player is to be respawned
* Called _before_ repositioning of player occurs
* return true in func to disable regular player placement
-* `minetest.register_on_prejoinplayer(func(name, ip))`
+* `minetest.register_on_prejoinplayer(function(name, ip))`
* Called before a player joins the game
* If it returns a string, the player is disconnected with that string as
reason.
-* `minetest.register_on_joinplayer(func(ObjectRef))`
+* `minetest.register_on_joinplayer(function(ObjectRef))`
* Called when a player joins the game
-* `minetest.register_on_leaveplayer(func(ObjectRef, timed_out))`
+* `minetest.register_on_leaveplayer(function(ObjectRef, timed_out))`
* Called when a player leaves the game
* `timed_out`: True for timeout, false for other reasons.
-* `minetest.register_on_auth_fail(func(name, ip))`
+* `minetest.register_on_auth_fail(function(name, ip))`
* Called when a client attempts to log into an account but supplies the
wrong password.
* `ip`: The IP address of the client.
* `name`: The account the client attempted to log into.
-* `minetest.register_on_cheat(func(ObjectRef, cheat))`
+* `minetest.register_on_cheat(function(ObjectRef, cheat))`
* Called when a player cheats
* `cheat`: `{type=<cheat_type>}`, where `<cheat_type>` is one of:
* `moved_too_fast`
* `finished_unknown_dig`
* `dug_unbreakable`
* `dug_too_fast`
-* `minetest.register_on_chat_message(func(name, message))`
+* `minetest.register_on_chat_message(function(name, message))`
* Called always when a player says something
* Return `true` to mark the message as handled, which means that it will
not be sent to other players.
-* `minetest.register_on_player_receive_fields(func(player, formname, fields))`
- * Called when a button is pressed in player's inventory form
+* `minetest.register_on_player_receive_fields(function(player, formname, fields))`
+ * Called when the server received input from `player` in a formspec with
+ the given `formname`. Specifically, this is called on any of the
+ following events:
+ * a button was pressed,
+ * Enter was pressed while the focus was on a text field
+ * a checkbox was toggled,
+ * something was selecteed in a drop-down list,
+ * a different tab was selected,
+ * selection was changed in a textlist or table,
+ * an entry was double-clicked in a textlist or table,
+ * a scrollbar was moved, or
+ * the form was actively closed by the player.
+ * Fields are sent for formspec elements which define a field. `fields`
+ is a table containing each formspecs element value (as string), with
+ the `name` parameter as index for each. The value depends on the
+ formspec element type:
+ * `button` and variants: If pressed, contains the user-facing button
+ text as value. If not pressed, is `nil`
+ * `field`, `textarea` and variants: Text in the field
+ * `dropdown`: Text of selected item
+ * `tabheader`: Tab index, starting with `"1"` (only if tab changed)
+ * `checkbox`: `"true"` if checked, `"false"` if unchecked
+ * `textlist`: See `minetest.explode_textlist_event`
+ * `table`: See `minetest.explode_table_event`
+ * `scrollbar`: See `minetest.explode_scrollbar_event`
+ * Special case: `["quit"]="true"` is sent when the user actively
+ closed the form by mouse click, keypress or through a button_exit[]
+ element.
+ * Special case: `["key_enter"]="true"` is sent when the user pressed
+ the Enter key and the focus was either nowhere (causing the formspec
+ to be closed) or on a button. If the focus was on a text field,
+ additionally, the index `key_enter_field` contains the name of the
+ text field. See also: `field_close_on_enter`.
* Newest functions are called first
* If function returns `true`, remaining functions are not called
-* `minetest.register_on_craft(func(itemstack, player, old_craft_grid, craft_inv))`
+* `minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv))`
* Called when `player` crafts something
* `itemstack` is the output
* `old_craft_grid` contains the recipe (Note: the one in the inventory is
* `craft_inv` is the inventory with the crafting grid
* Return either an `ItemStack`, to replace the output, or `nil`, to not
modify it.
-* `minetest.register_craft_predict(func(itemstack, player, old_craft_grid, craft_inv))`
+* `minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv))`
* The same as before, except that it is called before the player crafts, to
make craft prediction, and it should not change anything.
-* `minetest.register_allow_player_inventory_action(func(player, inventory, action, inventory_info))`
+* `minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info))`
* Determinates how much of a stack may be taken, put or moved to a
player inventory.
* `player` (type `ObjectRef`) is the player who modified the inventory
* `take`: Same as `put`
* Return a numeric value to limit the amount of items to be taken, put or
moved. A value of `-1` for `take` will make the source stack infinite.
-* `minetest.register_on_player_inventory_action(func(player, inventory, action, inventory_info))`
+* `minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info))`
* Called after a take, put or move event from/to/in a player inventory
* Function arguments: see `minetest.register_allow_player_inventory_action`
* Does not accept or handle any return value.
-* `minetest.register_on_protection_violation(func(pos, name))`
+* `minetest.register_on_protection_violation(function(pos, name))`
* Called by `builtin` and mods when a player violates protection at a
position (eg, digs a node or punches a protected entity).
* The registered functions can be called using
* The provided function should check that the position is protected by the
mod calling this function before it prints a message, if it does, to
allow for multiple protection mods.
-* `minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))`
+* `minetest.register_on_item_eat(function(hp_change, replace_with_item, itemstack, user, pointed_thing))`
* Called when an item is eaten, by `minetest.item_eat`
* Return `true` or `itemstack` to cancel the default item eat response
(i.e.: hp increase).
* `minetest.register_can_bypass_userlimit(function(name, ip))`
* Called when `name` user connects with `ip`.
* Return `true` to by pass the player limit
-* `minetest.register_on_modchannel_message(func(channel_name, sender, message))`
+* `minetest.register_on_modchannel_message(function(channel_name, sender, message))`
* Called when an incoming mod channel message is received
* You should have joined some channels to receive events.
* If message comes from a server mod, `sender` field is an empty string.
-Other registration functions
-----------------------------
-
-* `minetest.register_chatcommand(cmd, chatcommand definition)`
- * Adds definition to `minetest.registered_chatcommands`
-* `minetest.override_chatcommand(name, redefinition)`
- * Overrides fields of a chatcommand registered with `register_chatcommand`.
-* `minetest.unregister_chatcommand(name)`
- * Unregisters a chatcommands registered with `register_chatcommand`.
-* `minetest.register_privilege(name, definition)`
- * `definition`: `"description text"`
- * `definition`:
- `{description = "description text", give_to_singleplayer = boolean}`
- the default of `give_to_singleplayer` is true.
- * To allow players with `basic_privs` to grant, see `basic_privs`
- minetest.conf setting.
- * `on_grant(name, granter_name)`: Called when given to player `name` by
- `granter_name`.
- `granter_name` will be nil if the priv was granted by a mod.
- * `on_revoke(name, revoker_name)`: Called when taken from player `name` by
- `revoker_name`.
- `revoker_name` will be nil if the priv was revoked by a mod
- * Note that the above two callbacks will be called twice if a player is
- responsible, once with the player name, and then with a nil player name.
- * Return true in the above callbacks to stop register_on_priv_grant or
- revoke being called.
-* `minetest.register_authentication_handler(authentication handler definition)`
- * Registers an auth handler that overrides the builtin one
- * This function can be called by a single mod once only.
-
Setting-related
---------------
* Return value: Table with all node positions with a node air above
* Area volume is limited to 4,096,000 nodes
* `minetest.get_perlin(noiseparams)`
-* `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
+* `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
* Return world-specific perlin noise (`int(worldseed)+seeddiff`)
* `minetest.get_voxel_manip([pos1, pos2])`
* Return voxel manipulator object.
* mode = `"quick"`: Clear objects immediately in loaded mapblocks,
clear objects in unloaded mapblocks only when the
mapblocks are next activated.
+* `minetest.load_area(pos1[, pos2])`
+ * Load the mapblocks containing the area from `pos1` to `pos2`.
+ `pos2` defaults to `pos1` if not specified.
+ * This function does not trigger map generation.
* `minetest.emerge_area(pos1, pos2, [callback], [param])`
* Queue all blocks in the area from `pos1` to `pos2`, inclusive, to be
asynchronously fetched from memory, loaded from disk, or if inexistent,
Note that this parameter is mostly just a workaround and will be removed
in future releases.
* Creates a detached inventory. If it already exists, it is cleared.
+* `minetest.remove_detached_inventory(name)`
+ * Returns a `boolean` indicating whether the removal succeeded.
* `minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)`:
returns left over ItemStack.
* See `minetest.item_eat` and `minetest.register_on_item_eat`
Global tables
-------------
+### Registered definition tables
+
* `minetest.registered_items`
* Map of registered items, indexed by name
* `minetest.registered_nodes`
* Map of object references, indexed by active object id
* `minetest.luaentities`
* Map of Lua entities, indexed by active object id
-* `minetest.registered_chatcommands`
- * Map of registered chat command definitions, indexed by name
+* `minetest.registered_abms`
+ * List of ABM definitions
+* `minetest.registered_lbms`
+ * List of LBM definitions
+* `minetest.registered_aliases`
+ * Map of registered aliases, indexed by name
* `minetest.registered_ores`
- * List of registered ore definitions.
+ * Map of registered ore definitions, indexed by the `name` field.
+ * If `name` is nil, the key is the ID returned by `minetest.register_ore`.
* `minetest.registered_biomes`
- * List of registered biome definitions.
+ * Map of registered biome definitions, indexed by the `name` field.
+ * If `name` is nil, the key is the ID returned by `minetest.register_biome`.
* `minetest.registered_decorations`
- * List of registered decoration definitions.
+ * Map of registered decoration definitions, indexed by the `name` field.
+ * If `name` is nil, the key is the ID returned by
+ `minetest.register_decoration`.
+* `minetest.registered_schematics`
+ * Map of registered schematic definitions, indexed by the `name` field.
+ * If `name` is nil, the key is the ID returned by
+ `minetest.register_schematic`.
+* `minetest.registered_chatcommands`
+ * Map of registered chat command definitions, indexed by name
+* `minetest.registered_privileges`
+ * Map of registered privilege definitions, indexed by name
+
+### Registered callback tables
+
+All callbacks registered with [Global callback registration functions] are added
+to corresponding `minetest.registered_*` tables.
* `set_acceleration(acc)`
* `acc` is a vector
* `get_acceleration()`: returns the acceleration, a vector
-* `set_yaw(radians)`
+* `set_rotation(rot)`
+ * `rot` is a vector (radians). X is pitch (elevation), Y is yaw (heading)
+ and Z is roll (bank).
+* `get_rotation()`: returns the rotation, a vector (radians)
+* `set_yaw(radians)`: sets the yaw (heading).
* `get_yaw()`: returns number in radians
* `set_texture_mod(mod)`
* `get_texture_mod()` returns current texture modifier
* `hud_get_flags()`: returns a table of player HUD flags with boolean values.
* See `hud_set_flags` for a list of flags that can be toggled.
* `hud_set_hotbar_itemcount(count)`: sets number of items in builtin hotbar
- * `count`: number of items, must be between `1` and `23`
+ * `count`: number of items, must be between `1` and `32`
* `hud_get_hotbar_itemcount`: returns number of visible items
* `hud_set_hotbar_image(texturename)`
* sets background image for hotbar
* in first person view
* in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
* `get_eye_offset()`: returns `offset_first` and `offset_third`
+* `send_mapblock(blockpos)`:
+ * Sends a server-side loaded mapblock to the player.
+ * Returns `false` if failed.
+ * Resource intensive - use sparsely
+ * To get blockpos, integer divide pos by 16
`PcgRandom`
-----------
-------------
A perlin noise generator.
-It can be created via `PerlinNoise(seed, octaves, persistence, scale)`
+It can be created via `PerlinNoise(seed, octaves, persistence, spread)`
or `PerlinNoise(noiseparams)`.
-Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, scale)`
+Alternatively with `minetest.get_perlin(seeddiff, octaves, persistence, spread)`
or `minetest.get_perlin(noiseparams)`.
### Methods
pointable = true,
-- Overrides selection box when false
- visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
+ visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem" / "item",
-- "cube" is a node-sized cube.
-- "sprite" is a flat texture always facing the player.
-- "upright_sprite" is a vertical flat texture.
-- of its texture.
-- Otherwise for non-node items, the object will be an extrusion of
-- 'inventory_image'.
+ -- "item" is similar to "wielditem" but ignores the 'wield_image' parameter.
- visual_size = {x = 1, y = 1},
- -- `x` multiplies horizontal (X and Z) visual size.
- -- `y` multiplies vertical (Y) visual size.
+ visual_size = {x = 1, y = 1, z = 1},
+ -- Multipliers for the visual size. If `z` is not specified, `x` will be used
+ -- to scale the entity along both horizontal axes.
mesh = "model",
textures = {},
-- Number of required textures depends on visual.
- -- "cube" uses 6 textures in the way a node does.
+ -- "cube" uses 6 textures just like a node, but all 6 must be defined.
-- "sprite" uses 1 texture.
-- "upright_sprite" uses 2 textures: {front, back}.
-- "wielditem" expects 'textures = {itemname}' (see 'visual' above).
automatic_face_movement_max_rotation_per_sec = -1,
-- Limit automatic rotation to this value in degrees per second.
- -- No limit if value < 0.
+ -- No limit if value <= 0.
backface_culling = true,
-- Set to false to disable backface_culling for model
-- and not just for blocks that were saved last time before LBMs were
-- introduced to the world.
- action = func(pos, node),
+ action = function(pos, node),
}
Tile definition
sound = {
breaks = "default_tool_break", -- tools only
place = <SimpleSoundSpec>,
+ eat = <SimpleSoundSpec>,
},
- on_place = func(itemstack, placer, pointed_thing),
+ on_place = function(itemstack, placer, pointed_thing),
-- Shall place item and return the leftover itemstack.
-- The placer may be any ObjectRef or nil.
-- default: minetest.item_place
- on_secondary_use = func(itemstack, user, pointed_thing),
+ on_secondary_use = function(itemstack, user, pointed_thing),
-- Same as on_place but called when pointing at nothing.
-- The user may be any ObjectRef or nil.
-- pointed_thing: always { type = "nothing" }
- on_drop = func(itemstack, dropper, pos),
+ on_drop = function(itemstack, dropper, pos),
-- Shall drop item and return the leftover itemstack.
-- The dropper may be any ObjectRef or nil.
-- default: minetest.item_drop
- on_use = func(itemstack, user, pointed_thing),
+ on_use = function(itemstack, user, pointed_thing),
-- default: nil
-- Function must return either nil if no item shall be removed from
-- inventory, or an itemstack to replace the original itemstack.
-- The user may be any ObjectRef or nil.
-- The default functions handle regular use cases.
- after_use = func(itemstack, user, node, digparams),
+ after_use = function(itemstack, user, node, digparams),
-- default: nil
-- If defined, should return an itemstack and will be called instead of
-- wearing out the tool. If returns nil, does nothing.
place_param2 = nil, -- Force value for param2 when player places node
is_ground_content = true,
- -- If false, the cave generator will not carve through this node
+ -- If false, the cave generator and dungeon generator will not carve
+ -- through this node.
+ -- Specifically, this stops mod-added nodes being removed by caves and
+ -- dungeons when those generate in a neighbor mapchunk and extend out
+ -- beyond the edge of that mapchunk.
sunlight_propagates = false,
-- If true, sunlight will go infinitely through this node
legacy_wallmounted = false,
waving = 0,
- -- Valid for mesh, nodebox, plantlike, allfaces_optional nodes.
- -- 1 - wave node like plants (top of node moves, bottom is fixed)
+ -- Valid for drawtypes:
+ -- mesh, nodebox, plantlike, allfaces_optional, liquid, flowingliquid.
+ -- 1 - wave node like plants (node top moves side-to-side, bottom is fixed)
-- 2 - wave node like leaves (whole node moves side-to-side)
- -- caveats: not all models will properly wave.
- -- plantlike drawtype nodes can only wave like plants.
- -- allfaces_optional drawtype nodes can only wave like leaves.
+ -- 3 - wave node like liquids (whole node moves up and down)
+ -- Not all models will properly wave.
+ -- plantlike drawtype can only wave like plants.
+ -- allfaces_optional drawtype can only wave like leaves.
+ -- liquid, flowingliquid drawtypes can only wave like liquids.
sounds = {
footstep = <SimpleSoundSpec>,
dug = <SimpleSoundSpec>,
place = <SimpleSoundSpec>,
place_failed = <SimpleSoundSpec>,
+ fall = <SimpleSoundSpec>,
},
drop = "",
- -- Name of dropped node when dug. Default is the node itself.
- -- Alternatively:
+ -- Name of dropped item when dug.
+ -- Default dropped item is the node itself.
+ -- Using a table allows multiple items, drop chances and tool filtering:
drop = {
- -- Maximum number of items to drop
max_items = 1,
- -- Choose max_items randomly from this list
+ -- Maximum number of item lists to drop.
+ -- The entries in 'items' are processed in order. For each:
+ -- Tool filtering is applied, chance of drop is applied, if both are
+ -- successful the entire item list is dropped.
+ -- Entry processing continues until the number of dropped item lists
+ -- equals 'max_items'.
+ -- Therefore, entries should progress from low to high drop chance.
items = {
+ -- Entry examples.
{
- items = {"foo:bar", "baz:frob"}, -- Items to drop
- rarity = 1, -- Probability of dropping is 1 / rarity
- inherit_color = true, -- Inherit palette color from the node
+ -- 1 in 1000 chance of dropping a diamond.
+ -- Default rarity is '1'.
+ rarity = 1000,
+ items = {"default:diamond"},
+ },
+ {
+ -- Only drop if using a tool whose name is identical to one
+ -- of these.
+ tools = {"default:shovel_mese", "default:shovel_diamond"},
+ rarity = 5,
+ items = {"default:dirt"},
+ -- Whether all items in the dropped item list inherit the
+ -- hardware coloring palette color from the dug node.
+ -- Default is 'false'.
+ inherit_color = true,
+ },
+ {
+ -- Only drop if using a tool whose name contains
+ -- "default:shovel_".
+ tools = {"~default:shovel_"},
+ rarity = 2,
+ -- The item list dropped.
+ items = {"default:sand", "default:desert_sand"},
},
},
},
- on_construct = func(pos),
+ on_construct = function(pos),
-- Node constructor; called after adding node.
-- Can set up metadata and stuff like that.
-- Not called for bulk node placement (i.e. schematics and VoxelManip).
-- default: nil
- on_destruct = func(pos),
+ on_destruct = function(pos),
-- Node destructor; called before removing node.
-- Not called for bulk node placement.
-- default: nil
- after_destruct = func(pos, oldnode),
+ after_destruct = function(pos, oldnode),
-- Node destructor; called after removing node.
-- Not called for bulk node placement.
-- default: nil
- on_flood = func(pos, oldnode, newnode),
+ on_flood = function(pos, oldnode, newnode),
-- Called when a liquid (newnode) is about to flood oldnode, if it has
-- `floodable = true` in the nodedef. Not called for bulk node placement
-- (i.e. schematics and VoxelManip) or air nodes. If return true the
-- Default: nil
-- Warning: making a liquid node 'floodable' will cause problems.
- preserve_metadata = func(pos, oldnode, oldmeta, drops),
+ preserve_metadata = function(pos, oldnode, oldmeta, drops),
-- Called when oldnode is about be converted to an item, but before the
-- node is deleted from the world or the drops are added. This is
-- generally the result of either the node being dug or an attached node
-- "ItemStackMetaRef".
-- default: nil
- after_place_node = func(pos, placer, itemstack, pointed_thing),
+ after_place_node = function(pos, placer, itemstack, pointed_thing),
-- Called after constructing node when node was placed using
-- minetest.item_place_node / minetest.place_node.
-- If return true no item is taken from itemstack.
-- `placer` may be any valid ObjectRef or nil.
-- default: nil
- after_dig_node = func(pos, oldnode, oldmetadata, digger),
+ after_dig_node = function(pos, oldnode, oldmetadata, digger),
-- oldmetadata is in table format.
-- Called after destructing node when node was dug using
-- minetest.node_dig / minetest.dig_node.
can_dig = function(pos, [player]),
- on_punch = func(pos, node, puncher, pointed_thing),
+ on_punch = function(pos, node, puncher, pointed_thing),
-- Returns true if node can be dug, or false if not.
-- default: nil
-- default: minetest.node_punch
-- By default calls minetest.register_on_punchnode callbacks.
- on_rightclick = func(pos, node, clicker, itemstack, pointed_thing),
+ on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
-- default: nil
-- itemstack will hold clicker's wielded item.
-- Shall return the leftover itemstack.
-- This function does not get triggered by clients <=0.4.16 if the
-- "formspec" node metadata field is set.
- on_dig = func(pos, node, digger),
+ on_dig = function(pos, node, digger),
-- default: minetest.node_dig
-- By default checks privileges, wears out tool and removes node.
-- return true to run the timer for another cycle with the same timeout
-- value.
- on_receive_fields = func(pos, formname, fields, sender),
+ on_receive_fields = function(pos, formname, fields, sender),
-- fields = {name1 = value1, name2 = value2, ...}
-- Called when an UI form (e.g. sign text input) returns data.
+ -- See minetest.register_on_player_receive_fields for more info.
-- default: nil
- allow_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
-- Called when a player wants to move items inside the inventory.
-- Return value: number of items allowed to move.
- allow_metadata_inventory_put = func(pos, listname, index, stack, player),
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player),
-- Called when a player wants to put something into the inventory.
-- Return value: number of items allowed to put.
-- Return value -1: Allow and don't modify item count in inventory.
- allow_metadata_inventory_take = func(pos, listname, index, stack, player),
+ allow_metadata_inventory_take = function(pos, listname, index, stack, player),
-- Called when a player wants to take something out of the inventory.
-- Return value: number of items allowed to take.
-- Return value -1: Allow and don't modify item count in inventory.
- on_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
- on_metadata_inventory_put = func(pos, listname, index, stack, player),
- on_metadata_inventory_take = func(pos, listname, index, stack, player),
+ on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player),
+ on_metadata_inventory_put = function(pos, listname, index, stack, player),
+ on_metadata_inventory_take = function(pos, listname, index, stack, player),
-- Called after the actual action has happened, according to what was
-- allowed.
-- No return value.
- on_blast = func(pos, intensity),
+ on_blast = function(pos, intensity),
-- intensity: 1.0 = mid range of regular TNT.
-- If defined, called when an explosion touches the node, instead of
-- removing the node.
additional_wear = -0.02,
}
+Note: Tools with group `disable_repair=1` will not repairable by this recipe.
+
### Cooking
{
depth_riverbed = 2,
-- Node placed under river water and thickness of this layer
- node_cave_liquid = "default:water_source",
- -- Nodes placed as a blob of liquid in 50% of large caves.
- -- If absent, cave liquids fall back to classic behaviour of lava or
- -- water distributed according to a hardcoded 3D noise.
+ node_cave_liquid = "default:lava_source",
+ node_cave_liquid = {"default:water_source", "default:lava_source"},
+ -- Nodes placed inside 50% of the medium size caves.
+ -- Multiple nodes can be specified, each cave will use a randomly
+ -- chosen node from the list.
+ -- If this field is left out or 'nil', cave liquids fall back to
+ -- classic behaviour of lava and water distributed using 3D noise.
+ -- For no cave liquid, specify "air".
node_dungeon = "default:cobble",
-- Node used for primary dungeon structure.
* `()` signifies grouping. For example, when param1 and param2 are both
required, or only param3 is required: `(<param1> <param2>) | <param3>`
+Privilege definition
+--------------------
+
+Used by `minetest.register_privilege`.
+
+ {
+ description = "Can teleport", -- Privilege description
+
+ give_to_singleplayer = false,
+ -- Whether to grant the privilege to singleplayer (default true).
+
+ give_to_admin = true,
+ -- Whether to grant the privilege to the server admin.
+ -- Uses value of 'give_to_singleplayer' by default.
+
+ on_grant = function(name, granter_name),
+ -- Called when given to player 'name' by 'granter_name'.
+ -- 'granter_name' will be nil if the priv was granted by a mod.
+
+ on_revoke = function(name, revoker_name),
+ -- Called when taken from player 'name' by 'revoker_name'.
+ -- 'revoker_name' will be nil if the priv was revoked by a mod.
+
+ -- Note that the above two callbacks will be called twice if a player is
+ -- responsible, once with the player name, and then with a nil player
+ -- name.
+ -- Return true in the above callbacks to stop register_on_priv_grant or
+ -- revoke being called.
+ }
+
Detached inventory callbacks
----------------------------
Used by `minetest.create_detached_inventory`.
{
- allow_move = func(inv, from_list, from_index, to_list, to_index, count, player),
+ allow_move = function(inv, from_list, from_index, to_list, to_index, count, player),
-- Called when a player wants to move items inside the inventory.
-- Return value: number of items allowed to move.
- allow_put = func(inv, listname, index, stack, player),
+ allow_put = function(inv, listname, index, stack, player),
-- Called when a player wants to put something into the inventory.
-- Return value: number of items allowed to put.
-- Return value -1: Allow and don't modify item count in inventory.
- allow_take = func(inv, listname, index, stack, player),
+ allow_take = function(inv, listname, index, stack, player),
-- Called when a player wants to take something out of the inventory.
-- Return value: number of items allowed to take.
-- Return value -1: Allow and don't modify item count in inventory.
- on_move = func(inv, from_list, from_index, to_list, to_index, count, player),
- on_put = func(inv, listname, index, stack, player),
- on_take = func(inv, listname, index, stack, player),
+ on_move = function(inv, from_list, from_index, to_list, to_index, count, player),
+ on_put = function(inv, listname, index, stack, player),
+ on_take = function(inv, listname, index, stack, player),
-- Called after the actual action has happened, according to what was
-- allowed.
-- No return value.
Used by `minetest.register_authentication_handler`.
{
- get_auth = func(name),
+ get_auth = function(name),
-- Get authentication data for existing player `name` (`nil` if player
-- doesn't exist).
-- Returns following structure:
-- `{password=<string>, privileges=<table>, last_login=<number or nil>}`
- create_auth = func(name, password),
+ create_auth = function(name, password),
-- Create new auth data for player `name`.
-- Note that `password` is not plain-text but an arbitrary
-- representation decided by the engine.
- delete_auth = func(name),
+ delete_auth = function(name),
-- Delete auth data of player `name`.
-- Returns boolean indicating success (false if player is nonexistent).
- set_password = func(name, password),
+ set_password = function(name, password),
-- Set password of player `name` to `password`.
-- Auth data should be created if not present.
- set_privileges = func(name, privileges),
+ set_privileges = function(name, privileges),
-- Set privileges of player `name`.
-- `privileges` is in table form, auth data should be created if not
-- present.
- reload = func(),
+ reload = function(),
-- Reload authentication data from the storage location.
-- Returns boolean indicating success.
- record_login = func(name),
+ record_login = function(name),
-- Called when player joins, used for keeping track of last_login
- iterate = func(),
+ iterate = function(),
-- Returns an iterator (use with `for` loops) for all player names
-- currently in the auth database
}