3 GitHub Repo: https://github.com/minetest/minetest_game
9 The Minetest Game game offers multiple new possibilities in addition to the Minetest engine's built-in API,
10 allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
11 For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
14 * [XYZ] refers to a section the Minetest API
15 * [#ABC] refers to a section in this document
16 * [pos] refers to a position table `{x = -5, y = 0, z = 200}`
22 The bucket API allows registering new types of buckets for non-default liquids.
24 bucket.register_liquid(
25 "default:lava_source", -- name of the source node
26 "default:lava_flowing", -- name of the flowing node
27 "bucket:bucket_lava", -- name of the new bucket item (or nil if liquid is not takeable)
28 "bucket_lava.png", -- texture of the new bucket item (ignored if itemname == nil)
29 "Lava Bucket", -- text description of the bucket item
30 {lava_bucket = 1}, -- groups of the bucket item, OPTIONAL
31 false -- force-renew, OPTIONAL. Force the liquid source to renew if it has
32 -- a source neighbour, even if defined as 'liquid_renewable = false'.
33 -- Needed to avoid creating holes in sloping rivers.
36 The filled bucket item is returned to the player that uses an empty bucket pointing to the given liquid source.
37 When punching with an empty bucket pointing to an entity or a non-liquid node, the on_punch of the entity or node will be triggered.
44 "beds:bed", -- Bed name
45 def -- See [#Bed definition]
48 * `beds.can_dig(bed_pos)` Returns a boolean whether the bed at `bed_pos` may be dug
49 * `beds.read_spawns() ` Returns a table containing players respawn positions
50 * `beds.kick_players()` Forces all players to leave bed
51 * `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping
56 description = "Simple Bed",
57 inventory_image = "beds_bed.png",
58 wield_image = "beds_bed.png",
60 bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed.
61 top = {Tile definition} -- the tiles of the bottom part of the bed.
64 bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes])
65 top = 'regular nodebox', -- top part of bed (see [Node boxes])
67 selectionbox = 'regular nodebox', -- for both nodeboxes (see [Node boxes])
68 recipe = { -- Craft recipe
69 {"group:wool", "group:wool", "group:wool"},
70 {"group:wood", "group:wood", "group:wood"}
78 An ordered list of listnames (default: "main", "craft") of the player inventory,
79 that will be placed into bones or dropped on player death can be looked up or changed
80 in `bones.player_inventory_lists`.
82 e.g. `table.insert(bones.player_inventory_lists, "backpack")`
88 Use `creative.register_tab(name, title, items)` to add a tab with filtered items.
91 creative.register_tab("tools", "Tools", minetest.registered_tools)
93 is used to show all tools. Name is used in the sfinv page name, title is the
96 `is_enabled_for` is used to check whether a player is in creative mode:
98 creative.is_enabled_for(name)
100 Override this to allow per-player game modes.
102 The contents of `creative.formspec_add` is appended to every creative inventory
103 page. Mods can use it to add additional formspec elements onto the default
104 creative inventory formspec to be drawn after each update.
106 Group overrides can be used for any registered item, node or tool. Use one of
107 the groups stated below to pick which category it will appear in.
109 node = 1 -- Appears in the Nodes category
110 tool = 1 -- Appears in the Tools category
111 craftitem = 1 -- Appears in the Items category
117 The chests API allows the creation of chests, which have their own inventories for holding items.
119 `default.chest.get_chest_formspec(pos)`
121 * Returns a formspec for a specific chest.
122 * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
124 `default.chest.chest_lid_obstructed(pos)`
126 * Returns a boolean depending on whether or not a chest has its top obstructed by a solid node.
127 * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
129 `default.chest.chest_lid_close(pn)`
131 * Closes the chest that a player is currently looking in.
132 * `pn` The name of the player whose chest is going to be closed
134 `default.chest.open_chests`
136 * A table indexed by player name to keep track of who opened what chest.
137 * Key: The name of the player.
138 * Value: A table containing information about the chest the player is looking at.
139 e.g `{ pos = {1, 1, 1}, sound = null, swap = "default:chest" }`
141 `default.chest.register_chest(name, def)`
143 * Registers new chest
144 * `name` Name for chest e.g. "default:chest"
145 * `def` See [#Chest Definition]
149 description = "Chest",
151 "default_chest_top.png",
152 "default_chest_top.png",
153 "default_chest_side.png",
154 "default_chest_side.png",
155 "default_chest_front.png",
156 "default_chest_inside.png"
157 }, -- Textures which are applied to the chest model.
158 sounds = default.node_sound_wood_defaults(),
159 sound_open = "default_chest_open",
160 sound_close = "default_chest_close",
161 groups = {choppy = 2, oddly_breakable_by_hand = 2},
162 protected = false, -- If true, only placer can modify chest.
168 The doors mod allows modders to register custom doors and trapdoors.
170 `doors.registered_doors[name] = Door definition`
171 * Table of registered doors, indexed by door name
173 `doors.registered_trapdoors[name] = Trapdoor definition`
174 * Table of registered trap doors, indexed by trap door name
176 `doors.register_door(name, def)`
179 * `name` Name for door
180 * `def` See [#Door definition]
182 `doors.register_trapdoor(name, def)`
184 * Registers new trapdoor
185 * `name` Name for trapdoor
186 * `def` See [#Trapdoor definition]
188 `doors.register_fencegate(name, def)`
190 * Registers new fence gate
191 * `name` Name for fence gate
192 * `def` See [#Fence gate definition]
196 * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
197 * Returns an ObjectRef to a door, or nil if the position does not contain a door
201 :open(player) -- Open the door object, returns if door was opened
202 :close(player) -- Close the door object, returns if door was closed
203 :toggle(player) -- Toggle the door state, returns if state was toggled
204 :state() -- returns the door state, true = open, false = closed
206 the "player" parameter can be omitted in all methods. If passed then
207 the usual permission checks will be performed to make sure the player
208 has the permissions needed to open this door. If omitted then no
209 permission checks are performed.
211 `doors.door_toggle(pos, node, clicker)`
213 * Toggle door open or shut
214 * `pos` Position of the door
215 * `node` Node definition
216 * `clicker` Player definition for the player that clicked on the door
220 description = "Door description",
221 inventory_image = "mod_door_inv.png",
222 groups = {choppy = 2},
223 tiles = {"mod_door.png"}, -- UV map.
224 -- The front and back of the door must be identical in appearence as they swap on
226 recipe = craftrecipe,
227 sounds = default.node_sound_wood_defaults(), -- optional
228 sound_open = sound play for open door, -- optional
229 sound_close = sound play for close door, -- optional
230 protected = false, -- If true, only placer can open the door (locked for others)
231 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
232 -- optional function containing the on_rightclick callback, defaults to a doors.door_toggle-wrapper
234 ### Trapdoor definition
236 description = "Trapdoor description",
237 inventory_image = "mod_trapdoor_inv.png",
238 groups = {choppy = 2},
239 tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
240 tile_side = "doors_trapdoor_side.png",
241 -- The texture for the four sides of the trapdoor.
242 -- The texture should have the trapdoor side drawn twice, in the lowest and highest
243 -- 1/8ths of the texture, both upright. The area between is not used.
244 -- The lower 1/8th will be used for the closed trapdoor, the higher 1/8th will be used
245 -- for the open trapdoor.
246 sounds = default.node_sound_wood_defaults(), -- optional
247 sound_open = sound play for open door, -- optional
248 sound_close = sound play for close door, -- optional
249 protected = false, -- If true, only placer can open the door (locked for others)
250 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
251 -- function containing the on_rightclick callback
252 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
253 -- function containing the on_rightclick callback
255 ### Fence gate definition
257 description = "Wooden Fence Gate",
258 texture = "default_wood.png", -- `backface_culling` will automatically be
259 -- set to `true` if not specified.
260 material = "default:wood",
261 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
262 sounds = default.node_sound_wood_defaults(), -- optional
263 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
264 -- function containing the on_rightclick callback
270 The mod that places chests with loot in dungeons provides an API to register additional loot.
272 `dungeon_loot.register(def)`
274 * Registers one or more loot items
275 * `def` Can be a single [#Loot definition] or a list of them
277 `dungeon_loot.registered_loot`
279 * Table of all registered loot, not to be modified manually
285 -- ^ chance value from 0.0 to 1.0 that the item will appear in the chest when chosen
286 -- Due to an extra step in the selection process, 0.5 does not(!) mean that
287 -- on average every second chest will have this item
289 -- ^ table with minimum and maximum amounts of this item
290 -- optional, defaults to always single item
292 -- ^ table with minimum and maximum heights this item can be found at
293 -- optional, defaults to no height restrictions
295 -- ^ table with types of dungeons this item can be found in
296 -- supported types: "normal" (the cobble/mossycobble one), "sandstone"
297 -- "desert" and "ice"
298 -- optional, defaults to no type restrictions
304 Allows creation of new fences with "fencelike" drawtype.
306 `default.register_fence(name, item definition)`
308 Registers a new fence. Custom fields texture and material are required, as
309 are name and description. The rest is optional. You can pass most normal
310 nodedef fields here except drawtype. The fence group will always be added
315 name = "default:fence_wood",
316 description = "Wooden Fence",
317 texture = "default_wood.png",
318 material = "default:wood",
319 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
320 sounds = default.node_sound_wood_defaults(),
326 The walls API allows easy addition of stone auto-connecting wall nodes.
328 walls.register(name, desc, texture, mat, sounds)
329 ^ name = "walls:stone_wall". Node name.
330 ^ desc = "A Stone wall"
331 ^ texture = "default_stone.png"
332 ^ mat = "default:stone". Used to auto-generate crafting recipe.
333 ^ sounds = sounds: see [#Default sounds]
339 The farming API allows you to easily register plants and hoes.
341 `farming.register_hoe(name, hoe definition)`
342 * Register a new hoe, see [#hoe definition]
344 `farming.register_plant(name, Plant definition)`
345 * Register a new growing plant, see [#Plant definition]
347 `farming.registered_plants[name] = definition`
348 * Table of registered plants, indexed by plant name
354 description = "", -- Description for tooltip
355 inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
356 max_uses = 30, -- Uses until destroyed
357 material = "", -- Material for recipes
358 recipe = { -- Craft recipe, if material isn't used
359 {"air", "air", "air"},
368 description = "", -- Description of seed item
369 harvest_description = "", -- Description of harvest item
370 -- (optional, derived automatically if not provided)
371 inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
372 steps = 8, -- How many steps the plant has to grow, until it can be harvested
373 -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
374 minlight = 13, -- Minimum light to grow
375 maxlight = default.LIGHT_MAX -- Maximum light to grow
382 Add group flammable when registering a node to make fire seek for it.
383 Add it to an item to make it burn up when dropped in lava or fire.
384 New node def property:
388 * Called when fire attempts to remove a burning node.
389 * `pos` Position of the burning node.
391 `on_ignite(pos, igniter)`
393 * Called when Flint and steel (or a mod defined ignitor) is used on a node.
394 Defining it may prevent the default action (spawning flames) from triggering.
395 * `pos` Position of the ignited node.
396 * `igniter` Player that used the tool, when available.
399 Give Initial Stuff API
400 ----------------------
402 `give_initial_stuff.give(player)`
404 ^ Give initial stuff to "player"
406 `give_initial_stuff.add(stack)`
408 ^ Add item to the initial stuff
409 ^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
410 ^ Can be called after the game has loaded
412 `give_initial_stuff.clear()`
414 ^ Removes all items from the initial stuff
415 ^ Can be called after the game has loaded
417 `give_initial_stuff.get_list()`
419 ^ returns list of item stacks
421 `give_initial_stuff.set_list(list)`
423 ^ List of initial items with numeric indices.
425 `give_initial_stuff.add_from_csv(str)`
427 ^ str is a comma separated list of initial stuff
428 ^ Adds items to the list of items to be given
434 The player API can register player models and update the player's appearance.
436 * `player_api.register_model(name, def)`
437 * Register a new model to be used by players
438 * name: model filename such as "character.x", "foo.b3d", etc.
439 * def: See [#Model definition]
440 * saved to player_api.registered_models
442 * `player_api.registered_player_models[name]`
443 * Get a model's definition
444 * see [#Model definition]
446 * `player_api.set_model(player, model_name)`
447 * Change a player's model
448 * `player`: PlayerRef
449 * `model_name`: model registered with player_api.register_model()
451 * `player_api.set_animation(player, anim_name [, speed])`
452 * Applies an animation to a player
453 * anim_name: name of the animation.
454 * speed: frames per second. If nil, default from the model is used
456 * `player_api.set_textures(player, textures)`
457 * Sets player textures
458 * `player`: PlayerRef
459 * `textures`: array of textures, If `textures` is nil the default
460 textures from the model def are used
462 * `player_api.get_animation(player)`
463 * Returns a table containing fields `model`, `textures` and `animation`.
464 * Any of the fields of the returned table may be nil.
467 * `player_api.player_attached`
468 * A table that maps a player name to a boolean.
469 * If the value for a given player is set to true, the default player
470 animations (walking, digging, ...) will no longer be updated.
471 Knockback from damage is also prevented for that player.
476 animation_speed = 30, -- Default animation speed, in FPS.
477 textures = {"character.png", }, -- Default array of textures.
478 visual_size = {x = 1, y = 1}, -- Used to scale the model.
480 -- <anim_name> = {x = <start_frame>, y = <end_frame>},
481 foo = {x = 0, y = 19},
482 bar = {x = 20, y = 39},
485 collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, -- In nodes from feet position
486 stepheight = 0.6, -- In nodes
487 eye_height = 1.47, -- In nodes above feet position
494 `tnt.register_tnt(definition)`
496 ^ Register a new type of tnt.
498 * `name` The name of the node. If no prefix is given `tnt` is used.
499 * `description` A description for your TNT.
500 * `radius` The radius within which the TNT can destroy nodes. The default is 3.
501 * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
502 * `sound` The sound played when explosion occurs. By default it is `tnt_explode`.
503 * `disable_drops` Disable drops. By default it is set to false.
504 * `ignore_protection` Don't check `minetest.is_protected` before removing a node.
505 * `ignore_on_blast` Don't call `on_blast` even if a node has one.
506 * `tiles` Textures for node
507 * `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`.
508 * `top` Top tile. By default the name of the tnt with a suffix of `_top.png`.
509 * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
510 * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
512 `tnt.boom(position[, definition])`
514 ^ Create an explosion.
516 * `position` The center of explosion.
517 * `definition` The TNT definion as passed to `tnt.register` with the following addition:
518 * `explode_center` false by default which removes TNT node on blast, when true will explode center node.
520 `tnt.burn(position, [nodename])`
522 ^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
523 If no such callback exists, fallback to turn tnt group nodes to their
525 nodename isn't required unless already known.
527 To make dropping items from node inventories easier, you can use the
528 following helper function from 'default':
530 default.get_inventory_drops(pos, inventory, drops)
532 ^ Return drops from node inventory "inventory" in drops.
534 * `pos` - the node position
535 * `inventory` - the name of the inventory (string)
536 * `drops` - an initialized list
538 The function returns no values. The drops are returned in the `drops`
539 parameter, and drops is not reinitialized so you can call it several
540 times in a row to add more inventory items to it.
543 `on_blast` callbacks:
545 Both nodedefs and entitydefs can provide an `on_blast()` callback
547 `nodedef.on_blast(pos, intensity)`
548 ^ Allow drop and node removal overriding
549 * `pos` - node position
550 * `intensity` - TNT explosion measure. larger or equal to 1.0
551 ^ Should return a list of drops (e.g. {"default:stone"})
552 ^ Should perform node removal itself. If callback exists in the nodedef
553 ^ then the TNT code will not destroy this node.
555 `entitydef.on_blast(luaobj, damage)`
556 ^ Allow TNT effects on entities to be overridden
557 * `luaobj` - LuaEntityRef of the entity
558 * `damage` - suggested HP damage value
559 ^ Should return a list of (bool do_damage, bool do_knockback, table drops)
560 * `do_damage` - if true then TNT mod wil damage the entity
561 * `do_knockback` - if true then TNT mod will knock the entity away
562 * `drops` - a list of drops, e.g. {"wool:red"}
568 The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
569 To use it, add the `on_screwdriver` function to the node definition.
571 `on_rotate(pos, node, user, mode, new_param2)`
573 * `pos` Position of the node that the screwdriver is being used on
575 * `user` The player who used the screwdriver
576 * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
577 * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
578 * return value: false to disallow rotation, nil to keep default behaviour, true to allow
579 it but to indicate that changed have already been made (so the screwdriver will wear out)
580 * use `on_rotate = false` to always disallow rotation
581 * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
587 The sethome API adds three global functions to allow mods to read a players home position,
588 set a players home position and teleport a player to home position.
592 * `name` Player who's home position you wish to get
593 * return value: false if no player home coords exist, position table if true
595 `sethome.set(name, pos)`
597 * `name` Player who's home position you wish to set
598 * `pos` Position table containing coords of home position
599 * return value: false if unable to set and save new home position, otherwise true
603 * `name` Player you wish to teleport to their home position
604 * return value: false if player cannot be sent home, otherwise true
610 It is recommended that you read this link for a good introduction to the
611 sfinv API by its author: https://rubenwardy.com/minetest_modding_book/en/chapters/sfinv.html
617 * sfinv.set_page(player, pagename) - changes the page
618 * sfinv.get_page(player) - get the current page name. Will never return nil
619 * sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
620 * sfinv.register_page(name, def) - register a page, see section below
621 * sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
622 * Note: Page must already be defined, (opt)depend on the mod defining it.
623 * sfinv.set_player_inventory_formspec(player) - (re)builds page formspec
624 and calls set_inventory_formspec().
625 * sfinv.get_formspec(player, context) - builds current page's formspec
629 * sfinv.get_or_create_context(player) - gets the player's context
630 * sfinv.set_context(player, context)
634 * sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
635 * show_inv, defaults to false. Whether to show the player's main inventory
636 * size, defaults to `size[8,8.6]` if not specified
637 * sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or ""
641 * pages - table of pages[pagename] = def
642 * pages_unordered - array table of pages in order of addition (used to build navigation tabs).
643 * contexts - contexts[playername] = player_context
644 * enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
648 A table with these keys:
650 * page - current page name
651 * nav - a list of page names
652 * nav_titles - a list of page titles
653 * nav_idx - current nav index (in nav and nav_titles)
654 * any thing you want to store
655 * sfinv will clear the stored data on log out / log in
657 ### sfinv.register_page
659 sfinv.register_page(name, def)
661 def is a table containing:
663 * `title` - human readable page name (required)
664 * `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
665 * `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
666 * `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
667 * `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
668 * `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
672 Use sfinv.make_formspec to apply a layout:
674 return sfinv.make_formspec(player, context, [[
675 list[current_player;craft;1.75,0.5;3,3;]
676 list[current_player;craftpreview;5.75,1.5;1,1;]
677 image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
678 listring[current_player;main]
679 listring[current_player;craft]
680 image[0,4.25;1,1;gui_hb_bg.png]
681 image[1,4.25;1,1;gui_hb_bg.png]
682 image[2,4.25;1,1;gui_hb_bg.png]
683 image[3,4.25;1,1;gui_hb_bg.png]
684 image[4,4.25;1,1;gui_hb_bg.png]
685 image[5,4.25;1,1;gui_hb_bg.png]
686 image[6,4.25;1,1;gui_hb_bg.png]
687 image[7,4.25;1,1;gui_hb_bg.png]
690 See above (methods section) for more options.
692 ### Customising themes
694 Simply override this function to change the navigation:
696 function sfinv.get_nav_fs(player, context, nav, current_idx)
700 And override this function to change the layout:
702 function sfinv.make_formspec(player, context, content, show_inv, size)
704 size or "size[8,8.6]",
706 sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
712 return table.concat(tmp, "")
719 The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
720 delivered with Minetest Game, to keep them compatible with other mods.
722 `stairs.register_stair(subname, recipeitem, groups, images, description, sounds, worldaligntex)`
725 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
726 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
727 * `groups`: See [Known damage and digging time defining groups]
728 * `images`: See [Tile definition]
729 * `description`: Used for the description field in the stair's definition
730 * `sounds`: See [#Default sounds]
731 * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition]
733 `stairs.register_slab(subname, recipeitem, groups, images, description, sounds, worldaligntex)`
736 * `subname`: Basically the material name (e.g. cobble) used for the slab name. Nodename pattern: "stairs:slab_subname"
737 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
738 * `groups`: See [Known damage and digging time defining groups]
739 * `images`: See [Tile definition]
740 * `description`: Used for the description field in the slab's definition
741 * `sounds`: See [#Default sounds]
742 * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition]
744 `stairs.register_stair_inner(subname, recipeitem, groups, images, description, sounds, worldaligntex, full_description)`
746 * Registers an inner corner stair
747 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_inner_subname"
748 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
749 * `groups`: See [Known damage and digging time defining groups]
750 * `images`: See [Tile definition]
751 * `description`: Used for the description field in the stair's definition with "Inner" prepended
752 * `sounds`: See [#Default sounds]
753 * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition]
754 * `full_description`: Overrides the description, bypassing string concatenation. This is useful for translation. (optional)
756 `stairs.register_stair_outer(subname, recipeitem, groups, images, description, sounds, worldaligntex, full_description)`
758 * Registers an outer corner stair
759 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_outer_subname"
760 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
761 * `groups`: See [Known damage and digging time defining groups]
762 * `images`: See [Tile definition]
763 * `description`: Used for the description field in the stair's definition with "Outer" prepended
764 * `sounds`: See [#Default sounds]
765 * `worldaligntex`: A bool to set all textures world-aligned. Default false. See [Tile definition]
766 * `full_description`: Overrides the description, bypassing string concatenation. This is useful for translation. (optional)
768 `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds, worldaligntex)`
770 * A wrapper for stairs.register_stair, stairs.register_slab, stairs.register_stair_inner, stairs.register_stair_outer
771 * Uses almost the same arguments as stairs.register_stair
772 * `desc_stair`: Description for stair nodes. For corner stairs 'Inner' or 'Outer' will be prefixed
773 * `desc_slab`: Description for slab node
779 Creates panes that automatically connect to each other
781 `xpanes.register_pane(subname, def)`
783 * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
784 * `def`: See [#Pane definition]
790 "texture for front and back",
792 "texture for the 4 edges"
793 }, -- More tiles aren't supported
794 groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
795 sounds = SoundSpec, -- See [#Default sounds]
796 recipe = {{"","","","","","","","",""}}, -- Recipe field only
797 use_texture_alpha = true, -- Optional boolean (default: `false`) for colored glass panes
804 The following nodes use the group `connect_to_raillike` and will only connect to
805 raillike nodes within this group and the same group value.
806 Use `minetest.raillike_group(<Name>)` to get the group value.
808 | Node type | Raillike group name
809 |-----------------------|---------------------
810 | default:rail | "rail"
811 | tnt:gunpowder | "gunpowder"
812 | tnt:gunpowder_burning | "gunpowder"
815 If you want to add a new rail type and want it to connect with default:rail,
816 add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
823 Sounds inside the default table can be used within the sounds field of node definitions.
825 * `default.node_sound_defaults()`
826 * `default.node_sound_stone_defaults()`
827 * `default.node_sound_dirt_defaults()`
828 * `default.node_sound_sand_defaults()`
829 * `default.node_sound_wood_defaults()`
830 * `default.node_sound_leaves_defaults()`
831 * `default.node_sound_glass_defaults()`
832 * `default.node_sound_metal_defaults()`
838 `default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
844 `default.get_hotbar_bg(x, y)`
846 * Get the hotbar background as string, containing the formspec elements
847 * x: Horizontal position in the formspec
848 * y: Vertical position in the formspec
852 * Deprecated, remove from mods.
856 * Deprecated, remove from mods.
860 * Deprecated, remove from mods.
862 `default.gui_survival_form`
864 * Entire formspec for the survival inventory
866 `default.get_furnace_active_formspec(fuel_percent, item_percent)`
868 * Get the active furnace formspec using the defined GUI elements
869 * fuel_percent: Percent of how much the fuel is used
870 * item_percent: Percent of how much the item is cooked
872 `default.get_furnace_inactive_formspec()`
874 * Get the inactive furnace formspec using the defined GUI elements
880 To enable leaf decay for leaves when a tree is cut down by a player,
881 register the tree with the default.register_leafdecay(leafdecaydef)
884 If `param2` of any registered node is ~= 0, the node will always be
885 preserved. Thus, if the player places a node of that kind, you will
886 want to set `param2 = 1` or so.
888 The function `default.after_place_leaves` can be set as
889 `after_place_node of a node` to set param2 to 1 if the player places
890 the node (should not be used for nodes that use param2 otherwise
893 If the node is in the `leafdecay_drop` group then it will always be
896 `default.register_leafdecay(leafdecaydef)`
898 `leafdecaydef` is a table, with following members:
900 trunks = {"default:tree"}, -- nodes considered trunks
901 leaves = {"default:leaves", "default:apple"},
902 -- nodes considered for removal
903 radius = 3, -- radius to consider for searching
906 Note: all the listed nodes in `trunks` have their `on_after_destruct`
907 callback overridden. All the nodes listed in `leaves` have their
908 `on_timer` callback overridden.
914 Minetest Game dyes are registered with:
916 groups = {dye = 1, color_<color> = 1},
918 To make recipes that will work with dyes from many mods, define them using the
919 dye group and the color groups.
939 Example of one shapeless recipe using the dye group and a color group:
941 minetest.register_craft({
943 output = "<mod>:item_yellow",
944 recipe = {"<mod>:item_no_color", "group:dye,color_yellow"},
951 * `default.grow_tree(pos, is_apple_tree)`
952 * Grows a mgv6 tree or apple tree at pos
954 * `default.grow_jungle_tree(pos)`
955 * Grows a mgv6 jungletree at pos
957 * `default.grow_pine_tree(pos)`
958 * Grows a mgv6 pinetree at pos
960 * `default.grow_new_apple_tree(pos)`
961 * Grows a new design apple tree at pos
963 * `default.grow_new_jungle_tree(pos)`
964 * Grows a new design jungle tree at pos
966 * `default.grow_new_pine_tree(pos)`
967 * Grows a new design pine tree at pos
969 * `default.grow_new_snowy_pine_tree(pos)`
970 * Grows a new design snowy pine tree at pos
972 * `default.grow_new_acacia_tree(pos)`
973 * Grows a new design acacia tree at pos
975 * `default.grow_new_aspen_tree(pos)`
976 * Grows a new design aspen tree at pos
978 * `default.grow_bush(pos)`
979 * Grows a bush at pos
981 * `default.grow_acacia_bush(pos)`
982 * Grows an acaia bush at pos
984 * `default.grow_pine_bush(pos)`
985 * Grows a pine bush at pos
987 * `default.grow_blueberry_bush(pos)`
988 * Grows a blueberry bush at pos
995 "mycarts:myrail", -- Rail name
996 nodedef, -- standard nodedef
997 railparams -- rail parameter struct (optional)
1001 on_step(obj, dtime), -- Event handler called when
1003 acceleration, -- integer acceleration factor (negative
1007 The event handler is called after all default calculations
1008 are made, so the custom on_step handler can override things
1009 like speed, acceleration, player attachment. The handler will
1010 likely be called many times per second, so the function needs
1011 to make sure that the event is handled properly.
1017 The key API allows mods to add key functionality to nodes that have
1018 ownership or specific permissions. Using the API will make it so
1019 that a node owner can use skeleton keys on their nodes to create keys
1020 for that node in that location, and give that key to other players,
1021 allowing them some sort of access that they otherwise would not have
1022 due to node protection.
1024 To make your new nodes work with the key API, you need to register
1025 two callback functions in each nodedef:
1028 `on_key_use(pos, player)`
1029 * Is called when a player right-clicks (uses) a normal key on your
1031 * `pos` - position of the node
1032 * `player` - PlayerRef
1033 * return value: none, ignored
1035 The `on_key_use` callback should validate that the player is wielding
1036 a key item with the right key meta secret. If needed the code should
1037 deny access to the node functionality.
1039 If formspecs are used, the formspec callbacks should duplicate these
1040 checks in the metadata callback functions.
1043 `on_skeleton_key_use(pos, player, newsecret)`
1045 * Is called when a player right-clicks (uses) a skeleton key on your
1047 * `pos` - position of the node
1048 * `player` - PlayerRef
1049 * `newsecret` - a secret value(string)
1051 * `secret` - `nil` or the secret value that unlocks the door
1052 * `name` - a string description of the node ("a locked chest")
1053 * `owner` - name of the node owner
1055 The `on_skeleton_key_use` function should validate that the player has
1056 the right permissions to make a new key for the item. The newsecret
1057 value is useful if the node has no secret value. The function should
1058 store this secret value somewhere so that in the future it may compare
1059 key secrets and match them to allow access. If a node already has a
1060 secret value, the function should return that secret value instead
1061 of the newsecret value. The secret value stored for the node should
1062 not be overwritten, as this would invalidate existing keys.
1064 Aside from the secret value, the function should retun a descriptive
1065 name for the node and the owner name. The return values are all
1066 encoded in the key that will be given to the player in replacement
1067 for the wielded skeleton key.
1069 if `nil` is returned, it is assumed that the wielder did not have
1070 permissions to create a key for this node, and no key is created.
1072 `default.register_craft_metadata_copy(ingredient, result)`
1073 ----------------------------------------------------------
1075 This function registers a shapeless recipe that takes `ingredient`
1076 and `result` as input and outputs `result`.
1078 The metadata of the input `result` is copied to the output `result`.